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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How do I use Oracle from a UNIX C++ program (Pro C, OCI, etc)?

Re: How do I use Oracle from a UNIX C++ program (Pro C, OCI, etc)?

From: Toby T. <eric_petersonNOerSPAM_at_maurices.inrg.com.invalid>
Date: 2000/04/25
Message-ID: <0f10bc42.d5b5b0cf@usw-ex0106-047.remarq.com>#1/1

If you have the Oracle 7 Server SQL Reference book, look on page 4-147. Or look up in the V8 reference and look for the CONNECT clause. This should get you started. You need to do something like the following to connect
to the db using Pro*C:

    EXEC SQL BEGIN DECLARE SECTION;

      varchar vUsername[NAME_LEN];
      varchar vPassword[NAME_LEN];
      varchar vDBname[NAME_LEN];

    EXEC SQL END DECLARE SECTION;     // Set the character arrays to the username, password and db     // i.e.
    strcpy(vUsername.arr,'scott');
    strcpy(vPassword.arr,'tiger');
    strcpy(vDBname.arr,'testdb');

    // then set the .len of each to the length of each array.     vUsername.len = strlen((char *)vUsername.arr);     vPassword.len ......
    vDBname.len .......
    EXEC SQL CONNECT :vUsername
       IDENTIFIED BY :vPassword
               USING :vDBname;

Don't forget to issue a EXEC SQL COMMIT WORK RELEASE of EXEC SQL ROLLBACK WORK RELEASE when you exit the program.

HTH
T.

In article <3908ad3a.84187304_at_news-east.newscene.com>, chambers_at_inquiregroup.com (Don) wrote:
>I am writing a middle tier C++ program that will run on a UNIX
 system
>(HP-UX) and needs to connect to Oralce. Has anyone had success
 with
>this? What is the best way to do it?
>
>I have tried using Pro*C but it does not inetgrate well with our
>development environemnt (SoftBench). There is also very little
>documentation on it and Oracle tech support is no help with
 setup
>problems. They just tell me to look at a sample make file.
>
>I am considering using the Orcle Call Interface (OCI) but have
 never
>used it.
>
>I can't seem to find many books or any classes for Pro*C or OCI.
>
>Does anyone have any suggestions?
>
>I can use a third party tool if one is available but I would
 like to
>be able to use SQL statements if possible.
>
>
>Thanks,
> Don
> chamber_at_mindspring.com
>
>

Received on Tue Apr 25 2000 - 00:00:00 CDT

Original text of this message

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