Pro*C dynamic sql, ORA-22806 error on PREPARE [message #220693] |
Wed, 21 February 2007 10:23 |
ellens53
Messages: 1 Registered: February 2007 Location: Tampa, FL USA
|
Junior Member |
|
|
In Pro*C I want to vary the name of the sequence from which nextval is taken. The following works:
strcpy(dyn_sql, "SELECT ");
strcat(dyn_sql, acct_seq);
strcat(dyn_sql, ".nextval INTO :refno_03 FROM dual");
EXEC SQL at supdb EXECUTE IMMEDIATE :dyn_sql;
However, since this will be done many times, I want to prepare the statement and then supply the sequence name. I tried this:
strcpy(dyn_sql, "SELECT :seq_name");
strcat(dyn_sql, ".nextval INTO :refno_03 FROM dual");
EXEC SQL at supdb PREPARE S FROM :dyn_sql;
EXEC SQL at supdb EXECUTE S USING :acct_seq;
but got this error on the prepare:
ORA-22806: An attempt was made to extract an attribute from an item that is neither an object nor a REF
Please advise how I can prepare the statement.
Thanks!
|
|
|
|