Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pro*C Question

443104Jan 20 2008 — edited Mar 30 2008

Hi Expert,

I have been working with Oracle database for quite some time now, and did write some small programs in C (turbo C) during my college days. I haven't worked on Pro*C before.

Could the experts please guide me to how to make my first program run in Pro*c.

Operating System: IBM AIX 5.3.0.0 (ml 4)
Database: Oracle 10g Release 2 (10.2.0.3)

Below is my "simple.pc" program:

#include <stdio.h>
#include <sqlca.h>      /* SQL Communications Area */

#define     UNAME_LEN      20   /* Varchar limits */
#define     PWD_LEN        40

VARCHAR     username[UNAME_LEN];  /* SQL vars for        */
VARCHAR     password[PWD_LEN];    /* username and passwd */

int main(){

        strncpy((char *) username.arr, "SCOTT", UNAME_LEN);
        username.len = strlen((char *) username.arr);

        strncpy((char *) password.arr, "TIGER", PWD_LEN);
        password.len = strlen((char *) password.arr);

        EXEC SQL CONNECT :username IDENTIFIED BY :password;

        printf("Connected to the database as user: %s\n", username.arr);
        
        return(0);
}

I did try to dig into documentation, but wasn't succesfully.

You little insight would save hours for me.

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2008
Added on Jan 20 2008
33 comments
15,918 views