Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Are Questions about OCCI on topic?

Re: Are Questions about OCCI on topic?

From: <work_at_linux.local>
Date: Sat, 27 Apr 2002 13:16:23 GMT
Message-ID: <slrnaclcor.21h.work@linux.local>


NorwoodThree schrieb im Artikel <ba03e2c.0204261040.409ea6aa_at_posting.google.com>:
> Sure..what is your question?

Thank you, I just wanted to be shure I am not off topic. So here is my question (and please don't be too harsh on my English. PM about correcting my style, grammar or spelling are very welcome, though!):

I am evaluating Oracle 9i database for a rather complex project our company is probably going to start. We need to do it in C++ and developement will be done entirely on Linux, so I thought to give OCCI a try.

While trying to do some simple things I encountered a Problem, that is, if I create an Environment Object, a Connection Object and a Statement Object, like stated in the OCCI docs, and try to insert a row into an existing table (with the appropriate privileges) everything works fine until the point I violate a Constraint in this table. If a Constraint is violated I get a crash. This astonishes me, because the critical part of the code is wrapped into a try{...} catch (SQLException ex) {...} construct.

My System is Linux 2.4.10-4GB as provided by SuSE Linux 7.3 and Oracle 9i. Compiler is g++ 2.95.3.

I have the following table:

CREATE SEQUENCE seq_a;
CREATE TABLE a(

        id      NUMBER(3)
                NOT NULL,
        test    VARCHAR(16)
                NOT NULL,
        CONSTRAINT      pk_a
                PRIMARY KEY(id)

);

And I have the following code snippet:

Environtment *penv = Environment::createEnvironment(); Connection *pconn = penv->createConnection("username", "password");

try{

        string queryString = "INSERT INTO a(id, test) VALUES (1, "Hello")";
        Statement *st = pconn->createStatement();
        st->setSQL(queryString);

        st->executeUpdate();    /* Crash here */
        pconn->commit();
} catch (SQLException ex) {
        cout    << endl << "Exception: " << endl << ex.what();
        pconn->rollback();

}

Now, the Problem is, that st->executeUpdate() leads to a crash, when the pk_a CONSTRAINT is violated. If pk_a is not violated, everything is fine.

Second Problem is, that st->executeUpdate() does *not* raise an exception, i.e. the chatch{...} part is never reached, which IMO is really odd.

The same problem occurs where I try to delete a dataset which does not exist in the database.

As you may have noted, the above example is very close to the OCCI examples provided with OCCI documentation. Strange thing, too: The *unchanged* examples provided with the OCCI Library crash for the same reason, too.

As I see, there are various possible explenations:

  1. OCCI documentation and samples are incorrect. (I do not think so?)
  2. OCCI library is somehow screwed on my system. (Installed with runInstaller)
  3. I am to stupid to use OCCI. (But then, why do the samples crash?)
  4. I am missing a g++ flag which enables exceptions. But as stated in the FAQ for gnu.g++.help my version of g++ should support exceptions "out of the box". So I do not think this may be the problem.

I do link the above program against libclntsh, libocci and libpthread. Same happens if I compile it without thread support.

Thank you for your time and (bopefully) suggestions

Johannes Lochmann Received on Sat Apr 27 2002 - 08:16:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US