Need to recover BIGSERIAL "primary key" value from an Informix stored procedure -


i have following stored procedure:

create procedure eukno(pk bigint, requestee varchar(20)) returning bigint; define eunid bigint; insert ent_uniq (eunid, eunreq) values (pk, requestee); return eunid; end procedure; 

i value inserted table need primary key value eunid returned exact value during insert. eunid bigserial primary key start value of 9999000000, on first insert, eunid automates produce 9999000001 stored procedure executed parameters (0, 'username') , primary automatically increased one. need retrieve exact uniq eunid @ time of insert many users request id in single moment.

the dbinfo('serial8') function returns value of key last serial8 column. you're inserting bigserial; need use dbinfo('bigserial') instead.

sql[2163]: create procedure eukno(pk bigint, requestee varchar(20))          > returning bigint;          > insert ent_uniq (eunid, eunreq) values (pk, requestee);          > return dbinfo('bigserial');          > end procedure; sql[2164]: execute procedure eukno(57, 'varieties'); 57 sql[2165]: execute procedure eukno(0, 'boredom'); 58 sql[2166]: 

note serial 4-byte serial type; both serial8 , bigserial support 8-byte ranges of serial numbers, bigserial better type use (for variety of reasons).

you might note in code, local variable eunid both separate ent_uniq.eunid column (it happens have same name column, that's all), , either uninitialized when returned or unused.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -