Getting the value of a serial data type after inserting..
Posted in 2000
Topics: Stored Procedures & SPL, Data Types & Schema Design, Versions, Editions & End-of-Life
Hello: I'm working with IDS 7.31 under Windows NT I'd like to know how to retrive the value than a serial data type asigns when a new row is inserted to a table. Is there a way that I can return that value in a stored procedure? Elsa Perales Garza Grupo Internacional de Tecnologia e-mail: eperales@gint.con.mx
SELECT DBINFO( 'sqlca.sqlerrd2' ) FROM systables WHERE tabid = 1; This should be executed after each INSERT SQL before any other SQL. Rgds Elsa Perales wrote: > Hello: > I'm working with IDS 7.31 under Windows NT > > I'd like to know how to retrive the value than a serial data type asigns > when a new row is inserted to a table. > Is there a way that I can return that value in a stored procedure? > > Elsa Perales Garza > Grupo Internacional de Tecnologia > e-mail: eperales@gint.con.mx
In stored procedure You may simply use: ... let last_serial_val = DBINFO( 'sqlca.sqlerrd2' ); ...
Actually, I think it is dbinfo('sqlca.sqlerrd1'). dbinfo('sqlca.sqlerrd2') returns the number of rows inserted/deleted/updated/selected. Jay Buckler Victor Vat <victor@rpolice.ru> wrote in message news:948345335.30000@grave... > In stored procedure You may simply use: > ... > let last_serial_val = DBINFO( 'sqlca.sqlerrd2' ); > ... > > >
Yes, You are right ! The 'sqlca.sqlerrd1' option returns a single integer that provides the last serial value inserted into a table in current user session. And 'sqlca.sqlerrd2' option returns a single integer that provides the number of rows processed by SELECT,INSERT,DELETE,UPDATE and EXECUTE PROCEDURE statements. Jay Buckler wrote in message ... >Actually, I think it is dbinfo('sqlca.sqlerrd1'). dbinfo('sqlca.sqlerrd2') >returns the number of rows inserted/deleted/updated/selected. > >Jay Buckler