Re: Howto retrieve serial field after insert?
Posted in 2000
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi all,
What if the application that inserts into that table has many users,
and when you use DBINFO function the next record has been inserted into table
already.
What will you get then?
thanks
julia
Danail Cvetanov Danailov wrote:
> After INSERT use:
>
> LET var = DBINFO( "SQLCA.SQLERRD1" );
>
> Danail
>
> ----- Original Message -----
> From: "Ron M. Flannery" <rflanner@speedlink.net>
> To: "Dan Sjuls" <dan.sjuls@paf.fi>
> Cc: <informix-list@iiug.org>
> Sent: Wednesday, September 27, 2000 1:50 PM
> Subject: Re: Howto retrieve serial field after insert?
>
> > > How do I return the data from a serial field after a insert in a stored
> > > procedure?
> > >
> > > insert into table (x_serial) values (0)> >
> > Well in 4gl, you'd simply use the value of sqlca.sqlerrd[2]; I don't know
> > if it's available in a stored procedure. If not, try "select
> max(x_serial)
> > from table"..
> >
> >
"Ousmanov (Julia)" wrote:
> Hi all,
>
> What if the application that inserts into that table has many users,
> and when you use DBINFO function the next record has been inserted into table
> already.
> What will you get then?
>
> thanks
> julia
>
> Danail Cvetanov Danailov wrote:
>
> > After INSERT use:
> >
> > LET var = DBINFO( "SQLCA.SQLERRD1" );
> >
> > Danail
> >
> > ----- Original Message -----
> > From: "Ron M. Flannery" <rflanner@speedlink.net>
> > To: "Dan Sjuls" <dan.sjuls@paf.fi>
> > Cc: <informix-list@iiug.org>
> > Sent: Wednesday, September 27, 2000 1:50 PM
> > Subject: Re: Howto retrieve serial field after insert?
> >
> > > > How do I return the data from a serial field after a insert in a stored
> > > > procedure?
> > > >
> > > > insert into table (x_serial) values (0)> > >
> > > Well in 4gl, you'd simply use the value of sqlca.sqlerrd[2]; I don't know
> > > if it's available in a stored procedure. If not, try "select
> > max(x_serial)
> > > from table"..
> > >
> > >
sqlca variable information is for a particular session. So as long as no other
sql statements take place between the insert and the DBINFO('sqlca....') there
will not be issues.
Will
Not a problem. DBINFO is returning session specific information. The
engine places the serial number it inserted in the last record in your
session into a data structure that you are accessing with the DBINFO
function. If you do an insert and do not leave your session or perform
anyother SQL in between you could go on vacation for a year and assuming
the server stays up you will get the original serial value no matter how
many millions of rows were inserted while you were away.
Art S. Kagel
"Ousmanov (Julia)" wrote:
>
> Hi all,
>
> What if the application that inserts into that table has many users,
> and when you use DBINFO function the next record has been inserted into table
> already.
> What will you get then?
>
> thanks
> julia
>
> Danail Cvetanov Danailov wrote:
>
> > After INSERT use:
> >
> > LET var = DBINFO( "SQLCA.SQLERRD1" );
> >
> > Danail
> >
> > ----- Original Message -----
> > From: "Ron M. Flannery" <rflanner@speedlink.net>
> > To: "Dan Sjuls" <dan.sjuls@paf.fi>
> > Cc: <informix-list@iiug.org>
> > Sent: Wednesday, September 27, 2000 1:50 PM
> > Subject: Re: Howto retrieve serial field after insert?
> >
> > > > How do I return the data from a serial field after a insert in a stored
> > > > procedure?
> > > >
> > > > insert into table (x_serial) values (0)> > >
> > > Well in 4gl, you'd simply use the value of sqlca.sqlerrd[2]; I don't know
> > > if it's available in a stored procedure. If not, try "select
> > max(x_serial)
> > > from table"..
> > >
> > >