Env- createConnection failed

hello All,
please could you help me on this?
I'm trying to run a small c++ program using oracle occi.
i'm using visual c++ 7.1.
i have set the following in my vc++ environment:
include files:
c:\oracle\product\10.1.0\db_1\oci\include
library files:
c:\oracle\product\10.1.0\db_1\oci\MSVC\vc71
c:\oracle\product\10.1.0\db_1\oci\lib\MSVC
Executable files:
c:\oracle\product\10.1.0\db_1\bin
linker/input:
oraocci10.lib
my database is oracle9 and i'm using oracle 10lib files
the program compile and link fine:
but when i run it i receive the error :"unhandled exception at 0x612f89e9 in myproram.exe :0xC0000005: access violation reading location 0xcc006173"
the program stop in conn =env->createConnection ...
any help will be greatly appreciated

It's very simple!
There are many differences and normally you have only a chance, if you download the Patchset releases from the Metalink dictionary, because the basic and free downloadable versions have a lot of bugs. But for this process you have to be a registered customer. No chance for beginning developers and so they have not a good feeling to the Oracle software, because the first contact will be with strange difficult things. Not good to Oracle!
Ok, here the solution for your trouble:
You must create a Extension- or Standard-DLL in VC6 with the following content. The main problem ist with the Environment-object. And so we do it there, where it will be go.
By example:
__declspec( dllexport ) Environment* pEnv;
__declspec( dllexport ) Connection* pCon;
__declspec( dllexport ) void __cdecl OraConnect()
try
pEnv = Environment::createEnvironment( Environment::OBJECT );
RegisterClasses( pEnv );
pCon = pEnv->createConnection( "scott", "tiger", "" );
catch( SQLException &ex )
AfxMessageBox( ex.getMessage().c_str() );
__declspec( dllexport ) void __cdecl OraDisconnect()
try
pEnv->terminateConnection( pCon );
Environment::terminateEnvironment( pEnv );
catch( SQLException &ex )
AfxMessageBox( ex.getMessage().c_str() );
And by example in your VC7/7.1 Project you must import the declarations from above:
#include <occi.h>
#pragma comment(lib, "oraocci9.lib")
__declspec( dllimport ) oracle::occi::Environment* pEnv;
__declspec( dllimport ) oracle::occi::Connection* pCon;
__declspec( dllimport ) void OraConnect();
__declspec( dllimport ) void OraDisconnect();
And then you can do in VC7/VC7.1 with occi whatever you want!
If you need, I can make a complete sample with this unique cooperation to bypass this bug.
Many success
Robert
http://rarecase.xardas.lima-city.de/

Similar Messages

  • OCCI env- createConnection error

    Good day. hlp plz.
    Can't solve the problem.
    on conn = env->createConnection(username, password, db) got exception ORA-32102:Invalid OCI handle.
    Have a code:
         try
              env = Environment::createEnvironment (Environment::OBJECT);
              conn = env->createConnection(username, password, db);
         env->terminateConnection (conn);
              Environment::terminateEnvironment (env);
         catch(SQLException& e)
              cout<<e.what()<<endl;
    username = test, pass = XXX, db = testdb
    in tnsnames.ora alias testdb exists
    and command sqlplus test/XXX@testdb executes successfull;
    what i did wrong?

    VS2005
    oracle 9i (oraocci9.lib)
    tns
    testdb =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.1)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = WORK)
    Environment created successfully, connection not.
    if trying type username = TEST, instead of test then got Unhandled exception which can't handle even via catch(...){cout<<"Oops";}

  • Query running in one env and failing in other due to ORA-01779

    Hello All,
    I am running a query in one environment and it runs fine and when I try to run into other environment then it gives me a
    ORA-01779: cannot modify a column which maps to a non key-preserved table
    I am not sure where I am doing wrong. What can be the possible reasons for that?
    Thanks
    Lee

    Did you look up the error in the Error Messages documentation ?
    01779, 00000, "cannot modify a column which maps to a non key-preserved table"
    // *Cause: An attempt was made to insert or update columns of a join view which
    //         map to a non-key-preserved table.
    // *Action: Modify the underlying base tables directly.Apparently, your "query" is a DML statement that is attempting to update a view that is a join of two tables.
    Hemant K Chitale

  • Occi::environment createConnection throws exception

    Hi there,
    I tried connecting to my Oracle 11g database in debug mode but was unsuccessful. I am developing an ActiveX plugin using Visual Studio 2008. I downloaded OCCI 11.1.0.6.0 and instant client 11.2.0.1.0, extracted the the lib and dll files to my project directory, included the header files as part of my project include directory. Release mode works fine but it's debug that I am having issues with. When I link against oraocci11d.lib in debug mode, it gives me the error "error PRJ0050: Failed to register output. Please ensure you have the appropriate permissions to modify the registry." So then I linked against oraocci11.lib and was able to build successfully. However, I get the following error:
    try
              env = Environment::createEnvironment(Environment::DEFAULT);
              conn = env->createConnection("SYSTEM", "pwd", "remoteserver:1521/TEST"); //fails here
    env->terminateConnection(conn);
              Environment::terminateEnvironment(env);
    catch (SQLException& e)
              std::cout<<e.what();
    First-chance exception at 0x7c812afb in iexplore.exe: Microsoft C++ exception: oracle::occi::SQLException at memory location 0x0013a748..
    First-chance exception at 0x7c812afb in iexplore.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
    I see that others are having slightly different issues with Debug mode but I did not see a resolution for any of them. Any help would be much appreciated!
    Edited by: user13168246 on Jun 25, 2010 4:08 PM

    Make sure you include th directory that contains all the necessary header files in your project. It should be in your installed oracle directory (eg. d:\app\oracle\product\11.2.0\dbhome_1\OCI\include) so point to that in Project Properties->C/C++->General->Additional Include Directories. Then link it to oraocci11d.lib under Project Properties->Linker->Input->Additional Dependencies. Also include the following DLLs oraociei11.dll, oraocci11d.dll, oraocci11.dll, orannzsbb11.dll in your debug and release directories.

  • Occi compile fail

    my occi first source is below.
    #include <iostream>
    #include <occi.h>
    using namespace std;
    using namespace oracle::occi;
    int main(int argc, char* argv[])
    Environment *env = Environment::createEnvironment();
    Connection *conn = env->createConnection("wiesm","jwofjwi");
    Statement stmt = conn->createStatement("select count() from log_ids where agg_start_dt = '20110513'");
    ResultSet *rs = stmt->executeQuery();
    rs->next();
    int nCount = rs->getInt(1);
    cout << "log_ids count(20110513):" << nCount << endl;
    stmt->closeResultSet(rs);
    conn->terminateStatement(stmt);
    env->terminateConnection(conn);
    Environment::terminateEnvironment(env);
    return 0;
    $>g++ -I/oracle/product/10.2.0/db_1/rdbms/public -o ok ok.cc -L/oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2 -lclntsh -locci
    not defined symbol(below is error link message)
    __1cG__CrunKpure_error6F_v_ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cDstdbC__RTTI__1nDstdMlength_error__ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cDstdMout_of_range2T6M_v_ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2G6Mpkc_r1_ /oracle/product/10.2.0/db_1/instantclient32/instantclient
    _10_2/libocci.so
    __1cG__CrunIex_alloc6FI_pv_ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cG__CrunIex_throw6Fpvpkn0AQstatic_type_info_pF1_v_v_ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2G6Mrk1_r1_ /oracle/product/10.2.0/db_1/instantclient32/instantclient
    _10_2/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2t6MpkcIrkn0C__v_ /oracle/product/10.2.0/db_1/instantclient32/instant
    client_10_2/libocci.so
    __1cH__rwstdRexcept_msg_string2t6MIE_v_ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2t6Mpkcrkn0C__v_ /oracle/product/10.2.0/db_1/instantclient32/instantc
    lient_10_2/libocci.so
    __1cH__rwstdbC__rwse_StringIndexOutOfRange_ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cDstdZ__RTTI__1nDstdJbad_alloc__ /oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___Gassign6Mrk1II_r1_ /oracle/product/10.2.0/db_1/instantclient32/instan
    tclient_10_2/libocci.so
    ESHserver@/oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2 >ls -l
    total 202452
    lrwxrwxrwx 1 master00 oinstall 17 5월 16일 09:33 libclntsh.so -> libclntsh.so.10.1
    -rw-r--r-- 1 master00 oinstall 22747924 5월 16일 09:32 libclntsh.so.10.1
    -rw-r--r-- 1 master00 oinstall 6833692 5월 16일 09:32 libnnz10.so
    lrwxrwxrwx 1 master00 oinstall 15 5월 16일 09:34 libocci.so -> libocci.so.10.1
    -rw-r--r-- 1 master00 oinstall 1292828 5월 16일 09:32 libocci.so.10.1
    -rw-r--r-- 1 master00 oinstall 72678472 5월 16일 09:32 libociei.so
    please, help me.
    make=> $>g++ -I/oracle/product/10.2.0/db_1/rdbms/public -o ok ok.cc -L/oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2 -lclntsh -locci
    oracle 10g R2 10.2.0.5
    solaris 10 && lib32
    g++ 3.4.6

    Thank you for your answer.
    g++ -I/oracle/product/10.2.0/db_1/rdbms/public -o ok ok.cc -L/oracle/product/10.2.0/db_1/lib32 -L/oracle/product/10.2.0/db_1/instantclient32/instantclient_10_2 -lclntsh -locci
    as you mention, I insert "-L/oracle/product/10.2.0/db_1/lib32"
    but, compile failed ; hmm...
    __1cG__CrunKpure_error6F_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdbC__RTTI__1nDstdMlength_error__ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMout_of_range2T6M_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2G6Mpkc_r1_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunIex_alloc6FI_pv_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunIex_throw6Fpvpkn0AQstatic_type_info_pF1_v_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2G6Mrk1_r1_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2t6MpkcIrkn0C__v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cH__rwstdRexcept_msg_string2t6MIE_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2t6Mpkcrkn0C__v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cH__rwstdbC__rwse_StringIndexOutOfRange_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdZ__RTTI__1nDstdJbad_alloc__ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___Gassign6Mrk1II_r1_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunRex_chk_unexpected6F_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cH__rwstdX__rwse_InvalidSizeParam_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cH__rwstdbB__rwse_PosBeyondEndOfString_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___J__nullref_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdbC__RTTI__1nDstdMout_of_range__ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdLlogic_error2T6M_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___I__getRep6MII_pnH__rwstdM__string_ref4Ccn0B_n0C____ /oracle/product/1
    0.2.0/db_1/lib32/libocci.so
    __1cH__rwstdY__rwse_UnexpectedNullPtr_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___2t6Mrk1IIrkn0C__v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMlength_error2T6M_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*
    , void*, unsigned int), void (*)(void*, void*))/var/tmp//ccRKSoOw.o
    __1cG__CrunGex_get6F_pv_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdJexceptionG__vtbl_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdJbad_allocG__vtbl_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMlength_errorG__vtbl_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunMex_rethrow_q6F_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)/var/tmp//ccRKSoOw.o
    __1cDstdMout_of_rangeG__vtbl_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___Hcompare6kMIIpkcI_i_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cH__rwstdX__rwse_ResultLenInvalid_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunSregister_exit_code6FpG_v_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunHex_skip6F_b_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdMbasic_string4Ccn0ALchar_traits4Cc__n0AJallocator4Cc___Hreplace6MIIpkcIII_pc_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunIex_clean6F_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cG__CrunKex_rethrow6F_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdbB__RTTI__1nDstdLlogic_error__ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1cDstdLlogic_errorG__vtbl_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    c::c(N6, (int0_t)) /oracle/product/10.2.0/db_1/lib32/libocci.so
    c::c(n6, (int0_t)) /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1c2K6Fpv_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    __1c2k6Fpv_v_ /oracle/product/10.2.0/db_1/lib32/libocci.so
    ld: fatal...
    collect2: ld returned 1 exit status
    please, help me.

  • BPM worklist app, not working in Fusion SCM env..

    I have a small BPEL+HWF app, with the BPM worklist UI component. It works well on my laptop, but when deployed on SCM FusionApp env, it fails to load the BPM app_UI?
    I also noticed that the worklist app conf / ADF usage is different from my standalone laptop_SOA env and the FusionApp SOA_env. Are there any special steps to create/ register the HWF app UI in Fusion Apps Env?

    It is deploying correctly, the worklist app displays my instance. Btu when I click on my worklist item, the UI does not load or display. Below is the browser error and logfile error messages.
    -----Browser error-----
    Not Found
    The requested URL /workflow/DOO_Simulation_ProjectUI/faces/adf.task-flow was not found.
    ---Log file message---------
    Caused By: oracle.adf.controller.ControllerException: ADFC-12002: The ADF Controller is unable to pop the top-level ADF unbounded task flow from the page flow stack.
    at oracle.adfinternal.controller.state.PageFlowStack.pop(PageFlowStack.java:187. No
    8. No customization to env or app. This is a user defined (but standard) BPEL process deployed. The same app works fine on my local laptop & SOA env

  • OCCI: Problem with CreateConnection() method

    I am using OCCI sdk for Oracle 10g database with VS2005. I am continuously getting an exception
    "An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in OCCITest.exe
    Additional information: External component has thrown an exception."
    I get this exception at line:
    user = "SYSTEM";
    pass = "abc123";
    db = "//127.0.0.1:1521/orcl";
         ->     con = env->createConnection(user, pass, db);
    I have seen lots of posts with people asking this question... i tried almost all the alternatives specified in those posts. Even my Sqlplus works with this connection string. In sql plus, i can connect using these credentials, can create a table, insert data... etc. But I just can't connect from VC++...
    For reference, I am pasting the entry in my tnsnames.ora file below:
    ORCL =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = orcl)
    I am using Vista machine. I have installed oracle 10g for vista. Can my OS be a problem? I will really appreciate the help...
    Regards,
    Jwalant

    This may be obvious, but please verify that you have first created the environment before calling CreateConnection...
    Environment *env = Environment::createEnvironment (Environment::DEFAULT);
    Connection *con = env->createConnection (<user>, <password>, <connStr>);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ExecuteArrayUpdate fail! help me!

    Hi All,
    Please help me with this. I wrote a very simple code to insert data into Oracle table. But I found that, it was too slow. I try array insert feature and not succesful. When call stmt->executeArrayUpdate(3);, my program raised error immediately.
    I am using Oracle 9.2.0.6 on Windows 2000 Advanced Server.
    Environment* env = Environment::createEnvironment(Environment::THREADED_MUTEXED);
         Connection* conn = env->createConnection("test","z","CONN");
         Statement* stmt = conn->createStatement("insert into test(num) values(:1)");
         int it[10];
         it[0] = 1;
         it[1] = 2;
         it[2] = 3;
         it[3] = 4;
         ub4 inelements = 3;
         ub2 ilen[4];
         ilen[0] = sizeof(int);
         ilen[1] = sizeof(int);
         ilen[2] = sizeof(int);
         ilen[3] = sizeof(int);
         ub2 rc[4];
         rc[0] = 0;
         rc[1] = 0;
         rc[2] = 0;
         rc[3] = 0;
         int i = 1;
         stmt->setDataBufferArray(i++,it,OCCIINT,4,&inelements,sizeof(int),ilen,NULL,rc);
         stmt->executeArrayUpdate(3);
         conn->commit();
    Thank in advance.
    please send reply directly to [email protected]
    I am in a urgent!

    You need to use the setDataBuffer() interface :-
    stmt->setDataBuffer(i++,it,OCCIINT,sizeof(int),&ilen[0],NULL,rc);
    setDataBufferArray() should be used for PL/SQL tables.
    Regards.

  • Environment::createConnection throws unknown exception

    I just have such a simple code:
    Environment* env = Environment::createEnvironment();
         Connection* conn;
         try {
              conn = env->createConnection
    ("user", "passwd", "database");
         catch (SQLException exc)
              cout << exc.what();
              exit(0);
         catch (exception exc)
              cout << exc.what();
              exit(0);
         catch (...)
              cout << "Here I am!!!";
              exit(0);
         env->terminateConnection (conn);
    What kind of exception can be thrown from
    env->createConnection ("user", "passwd", "database");
    when it can't be catched by two previous handlers?
    I have compiled it under VC++ .NET 2003 and run
    under WinXP Professional with oracle 9.
    Thanks for advise a lot, ...

    OCCI libraries for developing applications with Visual C++ 7.0 (.NET 2002) are available in the 9.2.0.4 patchset. The default OCCI libraries work only with VC6.
    Oracle 10gR1 10.1.0.2 includes OCCI libraries for VC++ 7.0 and VC++ 7.1 (.NET 2003).
    The new libraries are installed under %ORACLE_HOME%\oci\lib\msvc\vc7 & %ORACLE_HOME%\oci\lib\msvc\vc71

  • VC++ 2005 and createConnection

    Tried it all. The Release version works... the Debug version crashes...?!
    Any good suggestions?

    I'm running into this same problem but not having any luck getting it to work. I've got a clean project set up that links to oraocci10(d).lib and have the instant client set up in its own directory. I've verified the paths are set up correctly.
    When using both the debug version and release version, I get an Unhandled exception (oracle:occi:SQLException) when calling env->createConnection(...).
    Even when I try to catch the exception, I can only get a numeric error code. If I try to get the text of the error, I get another access violation. It's like the entire Oracle environment is getting trashed when calling createConnection.
    I've tried using both the full (OTN) client as well, but the current OCCI library complains about a missing export (SQLBlob or something) in the full client.
    I went back to the demo included with the instant client SDK and compiled the occidml example, which compiled fine but crashed when creating the connection at runtime. This problem is obviously a library issue, not a user-source-code issue, so...
    Am I doing something wrong or is the software simply not functional now?
    Eric

  • -8020 Failed to Initialize Language

    hello people
    can any one help me on the following error os DI-API?
    Array ( [env:Code] => Array ( [env:Value] => env:Receiver [env:Subcode] => Array ( [env:Value] => -8020 ) ) [env:Reason] => Array ( [env:Text] => Failed to Initialize Language ) [env:Detail] => Array ( [Command] => Login ) )
    I have found the note 1272713 but the solution did not result.
    This is a webpage that is linked to SAP B1. the SAP version is V2007A SP1 PL10.
    please help.
    Miguel.

    Hello Miguel,
    Have you checked those threads?
    Re: Error code 8020 Failed to initilize langauge
    Language Init Error (8020) when connecting to the DI
    Thanks,
    Gordon

  • GetString in ocidml.cpp fails

    Hi.
    I've installed Oracle 9i release 9.2.0.1 and have compiled the ocidml.cpp - demo program. But when I run it the call to getString in DisplayAllRows create an Assertion failure (Debug). The program runs as expected if I remove the call to getString.
    Does anybody know what I can do about this?
    Thanks in advance!
    Ingrid

    ----- BEGIN CODE:
    * occidml - To exhibit the insertion, Selection, updating and deletion of
    * a row through OCCI.
    * Description
    * Create a program which has insert, select, update & delete as operations.
    * Perform all these operations using OCCI interface.
    #include <iostream>
    #include <occi.h>
    using namespace oracle::occi;
    using namespace std;
    class occidml
    private:
    Environment *env;
    Connection *conn;
    Statement *stmt;
    public:
    occidml (string user, string passwd, string db)
    env = Environment::createEnvironment (Environment::DEFAULT);
    conn = env->createConnection (user, passwd, db);
    ~occidml ()
    env->terminateConnection (conn);
    Environment::terminateEnvironment (env);
    * Insertion of a row with dynamic binding, PreparedStatement functionality.
    void insertBind (int c1, string c2)
    string sqlStmt = "INSERT INTO author_tab VALUES (:x, :y)";
    stmt=conn->createStatement (sqlStmt);
    try{
    stmt->setInt (1, c1);
    stmt->setString (2, c2);
    stmt->executeUpdate ();
    cout << "insert - Success" << endl;
    }catch(SQLException ex)
    cout<<"Exception thrown for insertBind"<<endl;
    cout<<"Error number: "<< ex.getErrorCode() << endl;
    cout<<ex.getMessage() << endl;
    conn->terminateStatement (stmt);
    * Inserting a row into the table.
    void insertRow ()
    string sqlStmt = "INSERT INTO author_tab VALUES (111, 'ASHOK')";
    stmt = conn->createStatement (sqlStmt);
    try{
    stmt->executeUpdate ();
    cout << "insert - Success" << endl;
    }catch(SQLException ex)
    cout<<"Exception thrown for insertRow"<<endl;
    cout<<"Error number: "<< ex.getErrorCode() << endl;
    cout<<ex.getMessage() << endl;
    conn->terminateStatement (stmt);
    * updating a row
    void updateRow (int c1, string c2)
    string sqlStmt =
    "UPDATE author_tab SET author_name = :x WHERE author_id = :y";
    stmt = conn->createStatement (sqlStmt);
    try{
    stmt->setString (1, c2);
    stmt->setInt (2, c1);
    stmt->executeUpdate ();
    cout << "update - Success" << endl;
    }catch(SQLException ex)
    cout<<"Exception thrown for updateRow"<<endl;
    cout<<"Error number: "<< ex.getErrorCode() << endl;
    cout<<ex.getMessage() << endl;
    conn->terminateStatement (stmt);
    * deletion of a row
    void deleteRow (int c1, string c2)
    string sqlStmt =
    "DELETE FROM author_tab WHERE author_id= :x AND author_name = :y";
    stmt = conn->createStatement (sqlStmt);
    try{
    stmt->setInt (1, c1);
    stmt->setString (2, c2);
    stmt->executeUpdate ();
    cout << "delete - Success" << endl;
    }catch(SQLException ex)
    cout<<"Exception thrown for deleteRow"<<endl;
    cout<<"Error number: "<< ex.getErrorCode() << endl;
    cout<<ex.getMessage() << endl;
    conn->terminateStatement (stmt);
    * displaying all the rows in the table
    void displayAllRows ()
    // string sqlStmt = "SELECT author_id, author_name FROM author_tab";
    string sqlStmt = "SELECT InSchema, Attribute FROM NameStore WHERE InSchema IN (SELECT TopConcept FROM ConceptTree START WITH SubConcept IN ( SELECT IsA FROM TypeOf WHERE LOWER(Instance) = LOWER('Hrúz Mária')) CONNECT BY SubConcept = PRIOR TopConcept) AND IsKey = 1 UNION SELECT InSchema, Attribute FROM NameStore WHERE InSchema IN (SELECT IsA FROM TypeOf WHERE LOWER(Instance) = LOWER('Hrúz Mária')) AND IsKey = 1 UNION SELECT InSchema, n.Attribute FROM NameStore n, Attributes a WHERE TypeOf IN (SELECT TopConcept FROM ConceptTree START WITH SubConcept IN ( SELECT IsA FROM TypeOf WHERE LOWER(Instance) = LOWER('Hrúz Mária')) CONNECT BY SubConcept = PRIOR TopConcept) AND n.Attribute = a.Attribute UNION SELECT InSchema, n.Attribute FROM NameStore n, Attributes a WHERE TypeOf IN (SELECT IsA FROM TypeOf WHERE LOWER(Instance) = LOWER('Hrúz Mária')) AND n.Attribute = a.Attribute";
    stmt = conn->createStatement (sqlStmt);
    ResultSet *rset = stmt->executeQuery ();
    try{
    while (rset->next ())
    cout << "author_id: " << rset->getString (1) << " author_name: "
    << rset->getString (2) << endl;
    }catch(SQLException ex)
    cout<<"Exception thrown for displayAllRows"<<endl;
    cout<<"Error number: "<< ex.getErrorCode() << endl;
    cout<<ex.getMessage() << endl;
    stmt->closeResultSet (rset);
    conn->terminateStatement (stmt);
    }; // end of class occidml
    int main (void)
    string user = "scott";
    string passwd = "tiger";
    string db = "";
    cout << "occidml - Exhibiting simple insert, delete & update operations"
    << endl;
    occidml *demo = new occidml (user, passwd, db);
    for( int loop = 0; loop < 20; loop++ )
    cout << "Displaying all rows after all the operations" << endl << endl;
    demo->displayAllRows ();
    delete (demo);
    cout << "occidml - done" << endl;
    ---- END CODE
    For first run it will terminate perfectly. Some others generates exceptions. SQL query generates 10 rows. For a perfect run it generates lines like
    Displaying all rows after all the operations
    author_id: anyafiú author_name: anya
    author_id: anyalány author_name: anya
    author_id: anyalány author_name: lány
    author_id: apalány author_name: lány
    author_id: helyszÃn_személy author_name: személy
    author_id: házastárs author_name: feleség
    author_id: időpont_személy author_name: személy
    author_id: nő author_name: női név
    author_id: személy author_name: személynév
    author_id: személy_terület author_name: személy
    Compile settings for Oracle9 client (9.2.0.1 with patchset 9.2.0.5):
    @SET ORACLE_HOME=C:\Oracle\Client9
    @SET INCLUDE=%INCLUDE%;%ORACLE_HOME%\oci\include;%ORACLE_HOME%\rdbms\demo
    @SET LIB=%LIB%;%ORACLE_HOME%\bin;%ORACLE_HOME%\oci\lib\msvc\vc7;%CPP_HOME%\lib;%ORACLE_HOME%\oci\lib\msvc\
    @SET LINK=/nod:libc /nodefaultlib:libcd
    @SET TNSNAMES=%ORACLE_HOME%\network\admin\tnsnames.ora
    @SET OPTIONS=/W3 /GX /EHsc /ML /O2 /D "WIN32COMMON" /D "_MT" /D "_MBCS" /D "_DLL" /D "_AFXDLL" /D "_WINDOWS" /D "NDEBUG" /D "WIN32"
    @SET CL=%T2% %OPTIONS% /I%ORACLE_HOME%\oci\include /o%OUTFILE%
    @SET PATH=%PATH%;%ORACLE_HOME%\bin
    @SET FILELIST=oci.lib msvcrt.lib msvcprt.lib oraocci9.lib
    @SET FILELIST=%FILELIST% occidml.cpp
    @cl.exe %FILELIST%
    ---- END COMPILE SETTINGS
    For a 10g client (10.1.0.2 with patchset 10.1.0.4) differences are:
    @SET ORACLE_HOME=C:\Oracle\Client10
    @SET FILELIST=oci.lib msvcrt.lib msvcprt.lib oraocci10.lib
    Computer: Intel P4 Prescott 3GHz, 1GB RAM
    Remote database: Oracle 10g on Linux (10.1.0.2)

  • CreateConnection error

    I just want to create a connection with database and the error 24960 occurred. But I set
    string user = "";
    password = "";
    db = "";
    So it is not too long as the error code show!! What should I do ?
    con = env->createConnection(user, passwd, db);
    ERROR DESCRIPTION:
    Error number: 24960
    ORA-24960: the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255
    OCIAttrGet with OCI_ATTR_USERNAME = -2
    I installed Oracle Client 10g.
    I have a C++ program an work with the Microsoft Visual C++ .NET 2005.
    Tks!!

    Regardless of the error, wouldn't it work better if you supplied a real username and password?
    Regards Nigel

  • Binary Values unreadable - Database corrupt?

    Hi,
    I'm experiencing a really weird problem here, I have a table with some varchar columns and two binary columns. What I do now, is to select data from it via Python with the following select statement:
    select * from torder where customerid=1624 order by torderid desc
    What happens is, that only for this customerid some binary data is missing, they contain an empty string. If I do the select like this:
    select * from torder where customerid=1624 order by torderid
    It does work, the data is there. With this, it works too:
    select * from torder order by torderid desc
    So it seems, the combination of "customerid=1624" and "desc" somehow corrupts the results.
    What's furthermore interesting is, that when I delete the last inserted row of the result, it works, and if I add a new one, it's broken again.
    I could not check if the error is Python-related or not, as I found no way to retrieve/display the binary data in sqlcli, as it displays only something like 0x8002637A6F70652E6931 , but I doubt that this has something to do with Python.
    Any clues of how to fix this?
    My database version is Kernel    7.6.06   Build 003-121-202-135 | X32/LINUX 7.6.06   Build 003-121-20
    2-135
    Previously, I had 7.6.03 and updated it to the above version, hoping that this would fix the problem, but it did not.
    Best Regards,
    Hermann Himmelbauer

    Ok, first many thanks for your quick reply. I did not answer at first as the problem magically went away. But unfortunately the problem is back today.
    <p/>
    The DDL statements look the following, there are no indexes on the table:
    <p/>
    <pre>
    CREATE TABLE torder (
            torderid INTEGER NOT NULL DEFAULT SERIAL,
            creation_date TIMESTAMP,
            transfer_date TIMESTAMP,
            signed_date TIMESTAMP,
            signed_with VARCHAR(3) CHECK (signed_with in ('TAN', 'BKU', 'MAN') OR signed_with IS NULL),
            revocation_date TIMESTAMP,
            done_date TIMESTAMP,
            formdata LONG BYTE NOT NULL,
            trans_function VARCHAR(30) NOT NULL CHECK (trans_function in ('do_bank_transfer', 'do_bank_collection',
                                    'do_cheque_transfer', 'do_cash', 'do_cashdraw')),
            trans_type VARCHAR(30) NOT NULL CHECK (trans_type in ('national','sepa','international')),
            applet_location VARCHAR(35),
            errors_text VARCHAR(100),
            errors LONG BYTE,
            customerid INTEGER,
            dbuserid INTEGER,
            torder_periodicid INTEGER,
            PRIMARY KEY (torderid),
             FOREIGN KEY(customerid) REFERENCES kunde (kundeid),
             FOREIGN KEY(dbuserid) REFERENCES dbuser (dbuserid),
             FOREIGN KEY(torder_periodicid) REFERENCES torder_periodic (torder_periodicid)
    </pre>
    <p/>
    The insert statements look the following (They are copied out of the SQLAlchemy SQL log), one can see that the binary values are inserted here:
    <p/>
    <pre>
    INFO:sqlalchemy.engine.base.Engine.0x...d110:INSERT INTO torder (creation_date, transfer_date, signed_date, si
    gned_with, revocation_date, done_date, formdata, trans_function, trans_type, applet_location, errors_text, err
    ors, customerid, dbuserid, torder_periodicid) VALUES (now(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    INFO:sqlalchemy.engine.base.Engine.0x...d110:['20091027113506345604', None, None, None, None, '\x80\x02}q\x01(
    U\x0bcharges_forq\x02U\x04bothq\x03U\x05dcodeq\x04U\x0588888q\x05U\x0ccurrency_isoq\x06U\x03EURq\x07U\x06valut
    aq\x08K\x00U\x11foreign_acc_name1q\tU\x11Foreign Account 2q\nU\x0cacc_payer_noq\x0bX\t\x00\x00\x00999111110q\x
    0cU\ttextlinesq\r]q\x0e(U\x0c1st transferq\x0fU\tMultilineq\x10U\x0bFor testingq\x11eU\x06amountq\x12cdecimal\
    nDecimal\nq\x13U\x071000.00\x85Rq\x14U\x0cacc_benef_noq\x15X\t\x00\x00\x00888111110q\x16U\x11foreign_acc_name2
    q\x17U\x0bfor Testingq\x18u.', 'do_bank_transfer', 'national', 'url:test_transfer', None, None, None, None, No
    ne]
    </pre>
    <p/>
    All rows are inserted with binary data, so it's never NULL and it's also never set to an empty string ('').
    <p/>
    But when reading back the rows, some binary values are an empty string.
    <p/>
    The following Python code illustrates the problem:
    <pre>
    import sapdb.dbapi
    def true_false_result(result):
        if result:
            return 'Bug begins'
        else:
            return 'Bug ends'
    def check_bincols(bdb, sqlcmd):
        print "----
        print "QUERY: %s" % sqlcmd
        print "----
        bdbc = bdb.cursor()
        bdbe = bdbc.execute(sqlcmd)
        bug_occured = False
        stored_bin_result = False
        while 1:
            row = bdbe.fetchone()
            if row is None:
                break
    Now check if the binary data results to an empty string,
    This should never happen (= the database bug)
            bin_result = (row[7]() == '')
            if bin_result != stored_bin_result:
                bug_occured = True
                print "Toggle to %s at torderid %s" % (
                    true_false_result(bin_result),
                    row[0])
                stored_bin_result = bin_result
        if not bug_occured:
            print "No Bug for this query"
        bdbe.close()
        bdbc.close()
    #bdb.close()
    if __name__ == '__main__':
        bdb = sapdb.dbapi.connect('USER', 'PASS', 'DBNAME', 'LOCALHOST')
    First try the original query, which results in a bug
        sqlcmd = 'select * from torder where customerid=1624 order by torderid desc'
        check_bincols(bdb, sqlcmd)
    This query normally is bugfree
        sqlcmd = 'select * from torder where customerid=1624 order by torderid'
        check_bincols(bdb, sqlcmd)
    This query has a bug, too
        sqlcmd = 'select * from torder order by torderid desc'
        check_bincols(bdb, sqlcmd)
    But this one not
        sqlcmd = 'select * from torder order by torderid'
        check_bincols(bdb, sqlcmd)
    This triggers the bug, too, which is curious as there's practically no ordering
        sqlcmd = 'select * from torder where customerid=1624 order by customerid desc'
        check_bincols(bdb, sqlcmd)
    So, it seems that the bug occurs only when using "DESC" for descending
    ordering.
    </pre>
    <p/>
    The output of this program is:
    <p/>
    <pre>
    QUERY: select * from torder where customerid=1624 order by torderid desc
    Toggle to Bug begins at torderid 1355
    Toggle to Bug ends at torderid 582
    QUERY: select * from torder where customerid=1624 order by torderid
    No Bug for this query
    QUERY: select * from torder order by torderid desc
    No Bug for this query
    QUERY: select * from torder order by torderid
    No Bug for this query
    QUERY: select * from torder where customerid=1624 order by customerid desc
    Toggle to Bug begins at torderid 1355
    Toggle to Bug ends at torderid 582
    </pre>
    <p/>
    So, it can be seen that the problem occurs ONLY when using descending ordering. Moreover it's interesting that the result for "select * from torder order by torderid desc" is sometimes buggy, sometimes not, which seems to be related if someone inserted some more rows or not. What's furthermore interesting is the last query, as there the order is applied to "customerid", which is the very same for every row, so there is no ordering and the bug occurs here, too.
    <p/>
    All this happens on my production instance. I have a testing environment, where I imported the very same data set (same database version etc.) and there is no such problem (for now), so it's quite complicated to nail down the problem further as I cannot easily disrupt the availability of the production instance.
    <p/>
    All I could do for now is not to use the "DESC" command and reorder the data in my application, but that is really suboptimal as I have to keep all results in memory.
    <p/>
    Any help is really appreciated!
    <p/>
    Best Regards,<BR>
    Hermann Himmelbauer
    <p>
    Update: I tried the same query with the following code with C++ / SQLDBC (I modified one of the SQLDBC examples):
    <p>
    <pre>
    First you have to include SQLDBC.h
    #include "SQLDBC.h"
    #include <stdio.h>
    typedef struct ConnectArgsT {
        char * username;
        char * password;
        char * dbname;
        char * host;
    } ConnectArgsT;
    static void parseArgs (ConnectArgsT * connectArgs, int argc, char **argv);
    using namespace SQLDBC;
    Let start your program with a main function
    int main(int argc, char *argv[])
       ConnectArgsT connectArgs;
       parseArgs (&connectArgs, argc, argv);
       char errorText[200];
    Every application has to initialize the SQLDBC library by getting a
    reference to the ClientRuntime and calling the SQLDBC_Environment constructor.
       SQLDBC_IRuntime *runtime;
       runtime = SQLDBC::GetClientRuntime(errorText, sizeof(errorText));
       if (!runtime) {
         fprintf(stderr, "Getting instance of the ClientRuntime failed %s", errorText);
         return (1);
       SQLDBC_Environment env(runtime);
    Create a new connection object and open a session to the database.
       SQLDBC_Connection *conn = env.createConnection();
       SQLDBC_Retcode rc;
       rc = conn->connect(connectArgs.host, connectArgs.dbname,
                          connectArgs.username, connectArgs.password);
       if(SQLDBC_OK != rc) {
         fprintf(stderr, "Connecting to the database failed %s", conn->error().getErrorText());
         return (1);
       printf("Sucessfull connected to %s as user %s\n",
              connectArgs.dbname, connectArgs.username);
    Create a new statment object and execute it.
       SQLDBC_Statement *stmt = conn->createStatement();
       rc = stmt->execute("select * from torder where customerid=1624 order by torderid desc");
       if(SQLDBC_OK != rc) {
         fprintf(stderr, "Execution failed %s", stmt->error().getErrorText());
         return (1);
    Check if the SQL command return a resultset and get a result set object.
       SQLDBC_ResultSet *result;
       result = stmt->getResultSet();
       if(!result) {
         fprintf(stderr, "SQL command doesn't return a result set %s", stmt->error().getErrorText());
         return (1);
    Position the curors within the resultset by doing a fetch next call.
       while (1) {
         rc = result->next();
         if(SQLDBC_OK != rc) {
           break;
           //fprintf(stderr, "Error fetching data %s", stmt->error().getErrorText());
           //return (1);
         char szString[30];
         char szString1[3000];
         SQLDBC_Length ind;
    Get a string value from the column.
         rc = result->getObject(1, SQLDBC_HOSTTYPE_ASCII, szString, &ind, sizeof(szString));
         if(SQLDBC_OK != rc) {
           fprintf(stderr, "Error getObject %s", stmt->error().getErrorText());
           return (1);
         rc = result->getObject(8, SQLDBC_HOSTTYPE_ASCII, szString1, &ind, sizeof(szString1));
         if(SQLDBC_OK != rc) {
           fprintf(stderr, "Error getObject %s", stmt->error().getErrorText());
           return (1);
         printf("%s %s\n", szString, szString1);
    Finish your program with a returncode.
       return 0;
    static void parseArgs (ConnectArgsT * connectArgs, int argc, char **argv)
    setting defaults for demo database
        connectArgs->username = (char*)"USER";
        connectArgs->password = (char*)"PASS";
        connectArgs->dbname = (char*)"MYDB";
        connectArgs->host = (char*)"localhost";
    use values from command line
        if (argc > 4) {
            connectArgs->host = argv [4];
        if (argc > 3) {
            connectArgs->dbname = argv [3];
        if (argc > 2) {
            connectArgs->password = argv [2];
        if (argc > 1) {
            connectArgs->username = argv [1];
    </pre>
    <p/>
    This works!! So it seems, that the problem is related to the Python module, which is interesting, as adding "DESC" should not be any difference to it. I personally suspect that there are some memory leaks in the code, which result in this strange behavior.
    <p/>
    Any suggestions?<p/>
    Best Regards<br>
    Hermann Himmelbauer
    Edited by: Hermann Himmelbauer on Oct 28, 2009 12:51 PM
    Edited by: Hermann Himmelbauer on Oct 28, 2009 12:55 PM

  • VC++ 2008 Express Edition, OCCI oraocci10d.dll 10.2.0.1, DB Oracle 10g

    I am not able to run some basic code using OCCI. I am able to successfully compile and link the code.
    using namespace oracle::occi;
    class occidml
    private:
         Environment *env;
         Connection *conn;
         Statement *stmt;
    public:
         occidml(string user, string passwd,string db)
              //env = Environment::createEnvironment(Environment::DEFAULT);
              env = Environment::createEnvironment();
              conn = env->createConnection(user, passwd,db);
    Every time the constructor is called, it successfully creates the environment it appears, I have a watch on the env pointer and it has some address. But the createConnection fails so I catch the exception and try to getMessage, but that fails with
    "Unhandled exception at 0x005b8dcb in Oracle_Proj.exe: 0xC0000005: Access violation reading location 0xcccccccc."
    I am using the occi sample code and havent changed much. please help me. I have a long way to go to make the app work. I can provide you with any additional information required.
    Chad

    My suspicion is that you are using mismatched versions between OCCI/Oracle Client and the Microsoft runtime libraries. That's why I've asked about the versions. I don't know what version of OCCI/Oracle Client you are using, but if it is the version that ships with Oracle Database Expression Edition, that will be incorrect since that version is for VS2003/VC7.1. One potential issue when using mismatched versions is that the memory allocators/deallocators used to build OCCI may be different from the runtime versions, for example.
    EDIT1: Also, if using the debug build, you'll need to make sure that the oraocciXXd.dll is in the path. If it's not you should get an "application unable to start" type of message though. I don't have an Oracle Database Express Edition install handy at the moment, so I'm going somewhat from memory.
    Thanks,
    Mark
    Edited by: Mark Williams on Sep 1, 2010 1:42 PM

Maybe you are looking for