Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Pro*C Prepared statements using CURRVAL/NEXTVAL

Pro*C Prepared statements using CURRVAL/NEXTVAL

From: Cary Gerber <carygerber_at_yahoo.com>
Date: 17 Sep 2001 08:53:52 -0700
Message-ID: <5dac3ab3.0109170753.6fe6b8f3@posting.google.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US