7 Replies Latest reply: Oct 29, 2012 11:41 PM by 970843 RSS

    OO4O and Standard C++

      How can I get the C++ classes of OO4O into a standard C++ program? I don't want to use ASP or anything, just the C++ interfaces with the database.
        • 1. Re: OO4O and Standard C++
          gdarling - oracle

          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;
          #include <stdlib.h>
          #include <stdio.h>
          #include <iostream.h>
          #include "oracl.h"

          int main( void )
               char szOutput[500];
               ODatabase odb;
               OValue val;

               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;
               return 0;
          • 2. Re: OO4O and Standard C++
            I installed the OO4O package, but I don't see oracl.h anywhere. Where is it?
            • 3. Re: OO4O and Standard C++
              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.
              • 4. Re: OO4O and Standard C++
                gdarling - oracle

                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
                • 5. Re: OO4O and Standard C++
                  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.

                  #ifndef WIN32
                  #define WIN32
                  • 6. Re: OO4O and Standard C++
                    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.
                    • 7. Re: OO4O and Standard C++
                      If it get failed in this line >>odb.ExecuteSQL("Begin get5 (:numparam); end;");
                      what might be the problem?