ORA-01036: illegal variable name/number

Clayton Arends

Member²
All,

I have just begun using DOA and I'm rather impressed with it. I am having a problem with it, however. Why does the following always cause the above Oracle Error?

OracleQuery1->Clear();
OracleQuery1->SQL->Add("select myfield into :pFieldVar from mytable");
OracleQuery1->DeclareVariable("pFieldVar", otInteger);
OracleQuery1->Execute();

During the execute the ORA-01036 exception is thrown. It happens at both design-time and run-time and only if I declare the variable. If I don't declare the variable the statement executes just fine but the pFieldVar variable cannot be accessed.

Thanks,

Clayton
 
It's just an idea, but are you sure that the otinteger Type is the right type. Have you tried otvariant, or otfloat or something?

Bye for now!
 
The error message that Oracle generates is a bit confusing. The problem is caused by the fact that a select ... into statement can only be used in PL/SQL. Therefore you need to use a PL/SQL block like this:

Code:
begin
  select myfield into :pFieldVar from mytable;
end;

------------------
Marco Kalter
Allround Automations
 
Thanks, I'll wrap it if I ever need to have the code that way. I was fooling around with the different commands and this one struck me as odd behavior. I'm doing just fine grabbing the results from the field itself.

Thanks again for the quick responses,
Clayton
 
Back
Top