This content has been marked as final. Show 7 replies
You just need to include "oracl.h" and link with oraclm32.lib.
I wouldnt encourage new development using OO4O however, as it's somewhat in maintenance mode these days. You may want to consider using the Oracle C++ Call Interface (OCCI) instead of OO4O.
Anyway, here's some code a simple oo4o c++ example.
create or replace procedure get5 (v1 out number) is
v1 := 5;
int main( void )
odb.Open("orcl", "scott", "tiger");
odb.GetParameters().Add("numparam",0, OPARAMETER_OUTVAR, OTYPE_NUMBER);
odb.ExecuteSQL("Begin get5 (:numparam); end;");
cout<< "value is " << (const char*) val<<endl;
I installed the OO4O package, but I don't see oracl.h anywhere. Where is it?
Wait, never mind, I found oracl.h, but your example doesn't work for me. First, I get that it can't find iostream.h, and when I replace it with <iostream>, I get a ton of errors, not the least of which are "undefined class _export" and all the variables are undeclared identifiers.
It compiles fine using VS6.
I just tried a console app using VS2005 via New > Project, and got the same errors.
I then tried using VS2005 to migrate the VS6 solution, and that worked OK. I didnt spend much time trying to fiddle with the switches to find out exactly why, but here is the resulting compile and link options in the working solution if you want to try to compare them.
Hope it helps,
/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_VC80_UPGRADE=0x0600" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Fp".\Debug/foo.pch" /Fo".\Debug/" /Fd".\Debug/" /FR".\Debug\\" /W3 /nologo /c /ZI /TP /errorReport:prompt
/OUT:".\Debug/foo.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:".\Debug\foo.exe.intermediate.manifest" /DEBUG /PDB:".\Debug/foo.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /ERRORREPORT:PROMPT oraclm32.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
I discovered that the problem was with the compiler. It was going to WIN16 not WIN32, so the _export command was being defined incorrectly. I added the following to the top of my code and it was all good.
Can you please post a few examples on procedure and package with procedures handling sinle and multiple queries,,like using SELECT and UPDATE in the same procedure.
If it get failed in this line >>odb.ExecuteSQL("Begin get5 (:numparam); end;");
what might be the problem?