How to get a just inserted serial value 
Author Message
 How to get a just inserted serial value
Hi!

I insert data into table:
insert into tblname values("0", ..

Frit sttibute is serial and I nedd that value in order to fill other tables
that depent on it.

Is there a way to get just inserted value of this serial attibute?

I use stored procedure.

Thanks!



Sat, 05 Jun 2004 18:43:08 GMT
 How to get a just inserted serial value

You can use the SQL function DBINFO to retrieve the last value inserted:

In SQL:
SELECT DBINFO ('sqlca.sqlerrd1')
FROM systables
where tabid = 1;

or in a stored procedure:

LET last_val = DBINFO ('sqlca.sqlerrd1')

From an ESQL/C program use variable sqlca.sqlerrd[1]

Partha Dutta


Quote:
> Hi!

> I insert data into table:
> insert into tblname values("0", ..

> Frit sttibute is serial and I nedd that value in order to fill other
tables
> that depent on it.

> Is there a way to get just inserted value of this serial attibute?

> I use stored procedure.

> Thanks!



Sat, 05 Jun 2004 19:35:42 GMT
 How to get a just inserted serial value

Hi Mario

The "0" implies character data you should use numeric:

insert into tblname values(0, ...

Cheers

Leon

Quote:
-----Original Message-----

Sent: Tuesday, December 18, 2001 12:43 PM

Subject: How to get a just inserted serial value

Hi!

I insert data into table:
insert into tblname values("0", ..

Frit sttibute is serial and I nedd that value in order to fill other tables
that depent on it.

Is there a way to get just inserted value of this serial attibute?

I use stored procedure.

Thanks!



Sat, 05 Jun 2004 20:53:11 GMT
 How to get a just inserted serial value

Hi all

(Red Faced... ) I neglected to mention that to get the serial value

you can use...

insert into tabname values(0,...);    
let y =  dbinfo("sqlca.sqlerrd1");

Sorry

Cheers

Leon

Quote:
-----Original Message-----
From: Leon Pappadopoulos
Sent: Tuesday, December 18, 2001 1:40 PM

Subject: RE: How to get a just inserted serial value

Hi Mario

The "0" implies character data you should use numeric:

insert into tblname values(0, ...

Cheers

Leon

-----Original Message-----

Sent: Tuesday, December 18, 2001 12:43 PM

Subject: How to get a just inserted serial value

Hi!

I insert data into table:
insert into tblname values("0", ..

Frit sttibute is serial and I nedd that value in order to fill other tables
that depent on it.

Is there a way to get just inserted value of this serial attibute?

I use stored procedure.

Thanks!



Sat, 05 Jun 2004 21:11:50 GMT
 How to get a just inserted serial value

Quote:
> insert into tabname values(0,...);
> let y =  dbinfo("sqlca.sqlerrd1");

This does the trick. ;) Thank you all for help!


Sun, 06 Jun 2004 17:58:38 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Getting SERIAL value when inserted with 0

2. Getting SERIAL value when inserted with 0

3. Getting serial value of just inserted record

4. Getting serial value of just inserted record

5. Getting value of serial column after insert insid

6. Getting values of serial columns from informix tables with VB/ADO 2.6

7. problem getting the last serial value

8. Getting Serial Value

9. Getting Serial value for Fragmented Tables

10. getting serial key after INSERT

11. Getting the serial number of latest inserted record in SP

12. Inserting values into a SERIAL field


 
Powered by phpBB® Forum Software