Home » Developer & Programmer » Precompilers, OCI & OCCI » Pro*C dynamic sql, ORA-22806 error on PREPARE
icon5.gif   Pro*C dynamic sql, ORA-22806 error on PREPARE [message #220693] Wed, 21 February 2007 10:23 Go to next message
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!
Re: Pro*C dynamic sql, ORA-22806 error on PREPARE [message #220784 is a reply to message #220693] Thu, 22 February 2007 02:14 Go to previous message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Hmm well it's the sequence that causing you this error.


Read this link

And search for the ORA-code
Previous Topic: Check This
Next Topic: Visual Basic 6 DLL + OCI
Goto Forum:
  


Current Time: Thu Mar 28 12:54:09 CDT 2024