Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: URGENT Oracle7 C++ precompiler.....
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
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
EXEC SQL INSERT INTO customers values (:CustomerId, :CustomerName);
return sqlca.sqlcode;
}
Proc*C header
int ORA_Customer_Insert (int CustomerId, char* CustomerName);
#ifdef cplusplus
}
#endif
Received on Wed Jul 01 1998 - 00:00:00 CDT
![]() |
![]() |