Getting Identity field for new record.

Getting Identity field for new record.

Post by Vince Varall » Sun, 03 May 1998 04:00:00



Hello

I am using RDO with SQL server.  When I need to insert a record and grab the
identity field I was doing it like this

rs.addnew
rs!field1 = "whatever"
rs.update
rs.bookmark  = rs.bookmark.lastmodified
id = rs!ID

Sometimes this worked, sometimes it didn't.
I know there is a way to create a stored procedure which will return the
newly created identity field but I don't know its syntax.  Does anyone know
how to do this.
Also, is there a way to return a value using an access query def.

Thanks
Vince Varallo

 
 
 

Getting Identity field for new record.

Post by Mikae » Tue, 12 May 1998 04:00:00


I am using something like this :

Create Procedure sp_InsertValueReturnIdentity
As
 SET NOCOUNT ON INSERT INTO tblTest(colName, colName)


It returns a variant (i think) that contains the ID.

I hope this help you
Mikael

Vince Varallo skrev i meddelandet ...

>Hello

>I am using RDO with SQL server.  When I need to insert a record and grab
the
>identity field I was doing it like this

>rs.addnew
>rs!field1 = "whatever"
>rs.update
>rs.bookmark  = rs.bookmark.lastmodified
>id = rs!ID

>Sometimes this worked, sometimes it didn't.
>I know there is a way to create a stored procedure which will return the
>newly created identity field but I don't know its syntax.  Does anyone know
>how to do this.
>Also, is there a way to return a value using an access query def.

>Thanks
>Vince Varallo



 
 
 

1. Capture the identity field assigned to the new inserted record

Hi,

How do I select the value of a identify field right after an insert
statement is executed ?

In my data_parent table, the rec_id is an identify field (auto number),
there is a data_child table which should contain the data_parent key
(rec_id), I need to capture the data_parent.rec_id right after I call the
insert in parent in order to setup the data_child with correct relationship.

Any suggestion is welcome.

Thanks.

Jean

2. Comparitive NVL Oracle Keyword in Access2.0

3. Retrieving the value of an identity field of a new record

4. Current time in Ingres

5. Identity field available when you create a new record

6. linked server question

7. Retrieving identity field value when adding new record

8. TechTips: Designing safer apps using local tables

9. Getting the new identity value from an Insert query

10. Getting the currently inserted record-id of a IDENTITY-Table

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

12. Getting Identity Fields from DataPump Task