Re: C, C++ interface for Oracle

From: Kevin Lukes <klukes_at_novatel.ca>
Date: 2 May 1994 22:07:36 GMT
Message-ID: <2q3tj8$m8j_at_fw.novatel.ca>


Roland Telfeyan (telfeyan_at_eecs.umich.edu) wrote:
: Does Oracle have a C or C++ library which gives one the ability to say things
: like:
 

: int Age;
: char Name[80];
 

: connect();
: composeSQL("select name, age from people");
: execSQL();
: stringBind(Name, 1);
: intBind(Age, 2);
: while (nextRow()){
: printf("Name = %s, Age = %d\n", Name, Age);
: }
 

: ???
 

: I'm sure there is, but what is the library called, and where is the
: documentation located?

You have a couple of options available: you can either use Pro*C which allows you to used embedded SQL statments in your program (the source for which is fed to the Pro*C pre-compiler before being passed on to the C compiler), or you can use the Oracle Call Interface (OCI) routines to provide (IMO) a more direct and cleaner approach to coding (the libraries for which, as I recall, are included in the Pro*C distribution). Using the latter approach would give the equivalent functions as per your original request:

   connect()      ->   olon()/orlon()
   composeSQL()   ->   osql3()
   execSQL()      ->   oexec()
   xxBind()       ->   obndrv()/obndrv()  * to bind input variables
                  ->   odefin()           * to bind output variables

There are a number of other functions available as well (eg ofetch to retrieve rows, ologof to log off, cursor routines, etc.).

I expect it's a matter of preference. I've worked with both and they each have there good and bad points. Using Pro*C with embedded SQL probably requires learning less syntax but conforming to the pre-compiler requirements can be somewhat restrictive (the pre-compiler also generates a *lot* of code - an entertaining feature during any debugging session).

Documentation for these features is contained in several manuals:

   Programmer's Guide to the ORACLE Precomilers    Pro*C Supplement to the ORACLE Precompilers Guide    ORACLE Call Interfaces (OCIs) Programmer's Guide


Kevin J. Lukes  Programmer/Analyst   |  klukes_at_novatel.ca
NovAtel Communications Ltd.          |  (403)295-4573
Calgary, Alberta CANADA              |  "Opinions expressed are my own"
===========================================================================
Lament of the Unknown Programmer:

    What a tangled web we weave, when multiple platforms we conceive


Received on Tue May 03 1994 - 00:07:36 CEST

Original text of this message