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: URGENT Oracle7 C++ precompiler.....

Re: URGENT Oracle7 C++ precompiler.....

From: Stephen Channell <stephen.channell_at_dial.pipex.com>
Date: 1998/07/01
Message-ID: <6ne4qk$l7b$1@flex.london.pipex.net>#1/1

The best way is not to put embedded SQL in C++ at all!

It's much better to use a C interface module called from C++. You get the advantage of pure C++ (structured exception handling and inline functions), AND you get to use the C parser in Pro*C to do the full checking on your code, including the full SQL & PL/SQL checking. You'll really start to accrue benefits when you need performance and want to use bind-arrays or threads (because you can stuff them into a C structure, and dynamically allocate & free them).

The following is example code for the two modules (just like manuals this codes not even sniffed a compiler!)

C++ module



#include "oracheader.h"

class Customer
{
private:

    int CustomerId;
    char CustomerName[100];
public:

    Insert ()
    {

        int sqlcode;
        if ((sqlcode = ORA_Customer_Insert (CustomerId, CustomerName))
            throw (new ORAError (sqlcode));
    };
}

Pro*C module



#include "oracheader.h"

EXEC SQL INCLUDE SQLCA; int ORA_Customer_Insert (int CustomerId, char* CustomerName) {

    EXEC SQL INSERT INTO customers values (:CustomerId, :CustomerName);     return sqlca.sqlcode;
}

Proc*C header



#ifdef cplusplus

extern "C" {
#endif

int ORA_Customer_Insert (int CustomerId, char* CustomerName);

#ifdef cplusplus

 }
#endif
Received on Wed Jul 01 1998 - 00:00:00 CDT

Original text of this message

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