IDENTITY_VAL_LOCAL() vs getGeneratedKeys()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

IDENTITY_VAL_LOCAL() vs getGeneratedKeys()

Paul J. Lucas
  I noticed that PreparedStatement has a getGeneratedKeys()
  method.  I assume it's an alternate means of getting generated
  key values that IDENTITY_VAL_LOCAL() would get.  So I tried it.
  However, getGeneratedKeys() returns null.  I tried called
  prepareStatement() with a second argument of an int[], but it
  says "not implemented."

  So is getGeneratedKeys() supposed to work?  Or must I use
  IDENTITY_VAL_LOCAL() ?

  - Paul
Reply | Threaded
Open this post in threaded view
|

Re: IDENTITY_VAL_LOCAL() vs getGeneratedKeys()

Satheesh Bandaram
This is http://issues.apache.org/jira/browse/DERBY-201. Derby currently
has limitations getting auto generated columns.

Satheesh

Paul J. Lucas wrote:

>     I noticed that PreparedStatement has a getGeneratedKeys()
>     method.  I assume it's an alternate means of getting generated
>     key values that IDENTITY_VAL_LOCAL() would get.  So I tried it.
>     However, getGeneratedKeys() returns null.  I tried called
>     prepareStatement() with a second argument of an int[], but it
>     says "not implemented."
>
>     So is getGeneratedKeys() supposed to work?  Or must I use
>     IDENTITY_VAL_LOCAL() ?
>
>     - Paul
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: IDENTITY_VAL_LOCAL() vs getGeneratedKeys()

Mamta Satoor
In reply to this post by Paul J. Lucas
Hi Paul,
 
org.apache.derbyTesting.functionTests.tests.jdbcap.autoGeneratedJdbc30.java class has a test (search for Test 6 in that class) and you will see that there is a positive test for PreparedStatement.getGeneratedKeys. Note that there is Statement.RETURN_GENERATED_KEYS passed to the Connection.prepareStatement. If you already do this and still get null from getGeneratedKeys for a single-row insert into a table with autogenerated key, then I will be curious into looking at the reproducible test case.
 
Mamta

 
On 5/13/05, Paul J. Lucas <[hidden email]> wrote:
       I noticed that PreparedStatement has a getGeneratedKeys()
       method.  I assume it's an alternate means of getting generated
       key values that IDENTITY_VAL_LOCAL() would get.  So I tried it.
       However, getGeneratedKeys() returns null.  I tried called
       prepareStatement() with a second argument of an int[], but it
       says "not implemented."

       So is getGeneratedKeys() supposed to work?  Or must I use
       IDENTITY_VAL_LOCAL() ?

       - Paul