Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Oracle Stored Procedure from Borland C++

Status
Not open for further replies.

350Zed

Programmer
Aug 30, 2007
13
GB
Hi,

I'm just starting out using Borland C++ and I've hit a problem that will be down to my lack of knowledge of the classes and functions that are available.

Anyway...

I am trying to execute an Oracle stored procedure using the following code:
TQuery* q = NULL; (This is declared in DBTables.HPP - Which I believe is a Borland class)

try
{
try
{
q = new TQuery(NULL);

q->SQL->Text = "EXECUTE ownername.storedprocedurename('" + parametervalue + "')";

q->ExecSQL();
}
catch(Exception& e)
{
//Error message blah, blah...
}
}
__finally
{
if(NULL != q)
{
q->Active = false;
delete q;
q = NULL;
}
}
(Most of this code has been taken from existing code else where in the application, as I'm new to this stuff I probably wont be able to answer any "why have you done that?" questions.)

Running this code results in an ORA-00900:Invalid SQL statement error. Researching this I know this occurs using execute immediate for SQL*Plus commands so I'm guessing this is the issue here, but I don't know what to try to fix it. Can anyone offer me any pointers?

Note: The procedure works when run from SQL*Plus using exactly the command in the code above. So I know the procedure compiles and runs.

Thanks.
 
did you try to print
q->SQL->Text
string?
does it look exactly as it runs un SQL Plus (quotes, parens, ...)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top