Re: Serial (autoincrement) field access
Posted in 1998
Troy Peterson wrote:
>I know this sounds dumb, but...
>
>I have 3 fields in the primary key for my table and one of them is of
>'serial' type. I want to insert a record into this table and then use the
>auto-assigned serial number from this field in a batch of records for
>another table.
>
>It seems awful sloppy to have to insert the record, run a query to try and
>find the record I just inserted, and then create my secondary batch of
>records. In my case this could result in multiple rows being returned and
>then I'm up a creek.
>
>Is there any way I can get my 'insert' to return the value of the
>autoincrement field? Is there a system variable that can be used?
>
>Any light you can shed on this topic would be greatly appreciated.
>
>
In SPL try:
dbinfo('sqlca.sqlerrd1')
In ESQL/C:
sqlca.sqlerrd[1]
In I4GL:
sqlca.sqlerrd[2]
Hope it helps.
Octav
--
Octav Chiriac Phone: (373) 2 21 20 96
NetInfo S.R.L. Fax: (373) 2 21 20 96
Chisinau (373) 2 24 00 83
Moldova, Republic of mailto:com@netinfo.moldova.net