getting identity value after insert

getting identity value after insert

Post by vic » Sun, 23 Mar 2003 00:59:35



How do you get the identity value of a row after an

but it returns 0 for all rows in the table.  Thanks.
 
 
 

getting identity value after insert

Post by David Murph » Sun, 23 Mar 2003 01:40:48


> How do you get the identity value of a row after an

> but it returns 0 for all rows in the table.  Thanks.

Vic - you are best to use a JDBC 3.0 driver which includes the API's to
retrieve the identity value. Please note that JDBC 3.0 does require JDK 1.4
or higher.

David Murphy
www.j-netdirect.com

 
 
 

getting identity value after insert

Post by Silvio Bierma » Tue, 25 Mar 2003 07:49:42



: How do you get the identity value of a row after an

: but it returns 0 for all rows in the table.  Thanks.


Silvio Bierman

 
 
 

1. Getting Identity Value on Insert

Is is possible to execute a single scrap of SQL (not a stored procedure)
that inserts a row and returns its identity.

For example: from SQL Query Analyzer I can execute:


And it returns:

    (1 row(s) affected)

    Identity
    ----------------------------------------
    126

    (1 row(s) affected)

If I attempt to execute the same SQL using an ADO command object, it appears
to execute correctly, but the resulting recordset is closed, so I can't get
the Identity value out of it:

    adoCommand.commandText = "insert into TableX (test) values ("Blah")

As 'Identity'"
    Set rs = adoCommmand.execute

now any action I take on the resulting recordset (rs) raises the error 3704:
The operation requested by the application is not allowed if the recordset
is closed.

Is there anyway to make this work?

Thanks

2. What is the difference between Ingres and Postgres?

3. Getting IDENTITY value BEFORE an insert(?!)

4. help:Oracle locks

5. Getting the value of an autoincrement or identity field during an sql insert

6. LPNMR'97: Final call for System Descriptions

7. Getting the value of an IDENTITY column after an INSERT query

8. Clearing results pane automatically

9. Getting auto-incremented identity value on insert...

10. Getting Back Identity column value on Insert using RDS

11. Getting IDENTITY value of a row that was just INSERTED

12. Getting the new identity value from an Insert query

13. Getting the value of an autoincrement or identity field during an sql insert