Re: Get Serial number from inside Informix Stored Procedure
Posted in 1999
Topics: Stored Procedures & SPL
On Fri, Jul 23, 1999 at 04:06:16PM +0100, Adrian Cho wrote:
> I have got a table, a column of which is a SERIAL type.
>
> Inside a Stored Procedure, I have an insert statement, which puts
> 0 into this particular column.
Inside stored procedures use :
dbinfo('sqlca.sqlerrd1') to get the last serial number
dbinfo('sqlca.sqlerrd2') to get the number of rows processed by
last update/delete statement
>
> So the database conviniently finds a suitable value for me, as SERIAL. So
> far so good
> Is there an easy way from SPL variables to tell what the SERIAL number was??
>
> What if this statement is executed thru' ADO, how to get the number?
I'm not sure about ADO, but the sollution could be the
same dbinfo() function.
>
> Also, it puzzled me that ADO or SP seemed to know how many rows were
> affected by an insert, update or delete statemnet. But what is the variable
> I can use to get the number of rows affected.
>
> Thanks in advance.
> Regards
> Adrian
>
Regards,
Octav
--
Octav Chiriac Phone: (373) 2 22 99 67
NetInfo S.R.L. Fax: (373) 2 21 36 59
Chisinau (373) 2 22 84 88
Moldova, Republic of mailto:com@netinfo-moldova.com
Is the serial value in the second field of the
sqlerrd array affected only by the current
transaction or does the value change for every
insert/update of a serial column on the database
server? It seems to me that the usefullness of
the dbinfo call is somewhat limited if other
transactions can inflect on the result retrieved.
Regards,
Jens Lydeking
In article <7nh3lv$d01$1@news.xmission.com>,
com@netinfo-moldova.com wrote:
>
>
> On Fri, Jul 23, 1999 at 04:06:16PM +0100,
Adrian Cho wrote:
> > I have got a table, a column of which is a
SERIAL type.
> >
> > Inside a Stored Procedure, I have an insert
statement, which puts
> > 0 into this particular column.
>
> Inside stored procedures use :
> dbinfo('sqlca.sqlerrd1') to get the lastserial number
> dbinfo('sqlca.sqlerrd2') to get the number ofrows processed by
> last update/delete
statement
>
> >
> > So the database conviniently finds a suitable
value for me, as SERIAL. So
> > far so good
> > Is there an easy way from SPL variables to
tell what the SERIAL number was??
> >
> > What if this statement is executed thru' ADO,
how to get the number?
>
> I'm not sure about ADO, but the sollution could
be the
> same dbinfo() function.
>
> >
> > Also, it puzzled me that ADO or SP seemed to
know how many rows were
> > affected by an insert, update or delete
statemnet. But what is the variable
> > I can use to get the number of rows affected.
> >
> > Thanks in advance.
> > Regards
> > Adrian
> >
>
> Regards,
> Octav
>
> --
> Octav Chiriac Phone:
(373) 2 22 99 67
> NetInfo S.R.L. Fax:
(373) 2 21 36 59
> Chisinau
(373) 2 22 84 88
> Moldova, Republic of
mailto:com@netinfo-moldova.com
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
The sqlerrd returns values specific to the last executed statement by the
current session or connection. Therefore the serial value returned is the
serial number assigned to the LAST row inserted by THAT session. Have no
fear.
Art S. Kagel
lydeking@my-deja.com wrote:
>
> Is the serial value in the second field of the
> sqlerrd array affected only by the current
> transaction or does the value change for every
> insert/update of a serial column on the database
> server? It seems to me that the usefullness of
> the dbinfo call is somewhat limited if other
> transactions can inflect on the result retrieved.
>
> Regards,
>
> Jens Lydeking
>
> In article <7nh3lv$d01$1@news.xmission.com>,
> com@netinfo-moldova.com wrote:
> >
> >
> > On Fri, Jul 23, 1999 at 04:06:16PM +0100,
> Adrian Cho wrote:
> > > I have got a table, a column of which is a
> SERIAL type.
> > >
> > > Inside a Stored Procedure, I have an insert
> statement, which puts
> > > 0 into this particular column.
> >
> > Inside stored procedures use :
> > dbinfo('sqlca.sqlerrd1') to get the last> serial number
> > dbinfo('sqlca.sqlerrd2') to get the number of> rows processed by
> > last update/delete
> statement
> >
> > >
> > > So the database conviniently finds a suitable
> value for me, as SERIAL. So
> > > far so good
> > > Is there an easy way from SPL variables to
> tell what the SERIAL number was??
> > >
> > > What if this statement is executed thru' ADO,
> how to get the number?
> >
> > I'm not sure about ADO, but the sollution could
> be the
> > same dbinfo() function.
> >
> > >
> > > Also, it puzzled me that ADO or SP seemed to
> know how many rows were
> > > affected by an insert, update or delete
> statemnet. But what is the variable
> > > I can use to get the number of rows affected.
> > >
> > > Thanks in advance.
> > > Regards
> > > Adrian
> > >
> >
> > Regards,
> > Octav
> >
> > --
> > Octav Chiriac Phone:
> (373) 2 22 99 67
> > NetInfo S.R.L. Fax:
> (373) 2 21 36 59
> > Chisinau
> (373) 2 22 84 88
> > Moldova, Republic of
> mailto:com@netinfo-moldova.com
> >
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.