| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Pro*C Prepared statements using CURRVAL/NEXTVAL
Why do I get this behavior? We design all our apps to prepare all
statements up front, because our database name can be switched at a
moment's notice.
/* Insert new trip plan */
sprintf(stmt,
"select %s.xyz_seq.nextval from dual ",
database
);
EXEC SQL prepare get_serial from :stmt;
if (!SQLOK()) exit(1);
exec sql execute get_serial into :curr_tp->db->xyz_seq;
if (!SQLOK()) exit(1);
This always yields 0 every time thru a loop...
exec sql select mydb.xyz_seq.nextval into :curr_tp->db->xyz_seq from dual;
if (!SQLOK()) exit(1);
This yields the right answer (next sequence) each time... but we have to hardcode our database/table name. Received on Mon Sep 17 2001 - 10:53:52 CDT
![]() |
![]() |