Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Elsa Perales asked how to retrieve the value a SERIAL column assigns on insert, including inside a stored procedure, on IDS 7.31 under Windows NT. Chetan Anand and Victor Vat suggested DBINFO('sqlca.sqlerrd2'); Jay Buckler corrected that to 'sqlca.sqlerrd1' (last serial value), since sqlerrd2 is rows processed, and Victor Vat agreed. Solved.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Elsa Perales — — source: Informix-list mailing list archive (1991-1998)
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
↪ replying to Elsa Perales
Chetan Anand — — source: Informix-list mailing list archive (1991-1998)
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
↪ replying to Elsa Perales
Victor Vat — — source: Informix-list mailing list archive (1991-1998)
In stored procedure You may simply use:
...
let last_serial_val = DBINFO( 'sqlca.sqlerrd2' );
...
↪ replying to Victor Vat
Jay Buckler — — source: Informix-list mailing list archive (1991-1998)
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' );
> ...
>
>
>
↪ replying to Jay Buckler
Victor Vat — — source: Informix-list mailing list archive (1991-1998)
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
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.