Re: C programming with oracle
Date: 1996/08/26
Message-ID: <3221F7F6.4636_at_acsatlanta.com>#1/1
William McCarroll wrote:
>
> Hello,
>
> In the near future I am looking at creating a Windows application that
> interfaces with oracle
> directly, I am trying to stay away from ODBC. Currently, I am only
> versed in programming
> PL/SQL when it comes to the database. I was wondering if anyone knew
> any good books or
> tutorials about programming for Oracle in C. Also, are there any
> libraries available that
> make this easier.. any input would be appreciated..
Have you considered pro-c?
If you have, then disregard the rest of this post.
If not, you might want to consider it. It will allow you to use
familar
PL/SQL syntax and the flexibility of C. It also hides some of the
ugly
details that you have to go through with the client library API. If
you
stick close to the ANSI standard, you can write code that will run
under
either Sybase or Oracle without having to do major work in a port.
The code to extract data from a table named foo would look like this:
EXEC SQL INCLUDE SQLCA; /* Include the communication area */
void main(int argc, char **argv){
EXEC SQL BEGIN DECLARE SECTION; /* Define Host variables */
char username[30]; char password[30]; char ename; int e_number;
EXEC SQL END DECLARE SECTION; argv++; /* Move pointer to first argument */
memcpy(username,argv,sizeof(username));
argv++; /* Move pointer to password */ memcpy(password,argv,sizeof(password));
EXEC SQL CONNECT :username IDENTIFIED BY :password;
e_number = 100; /* Set Employee number to 100 */
EXEC SQL SELECT EMPLOYEE from FOO into :ename where EMPLOYEE_ID = :e_number;
printf("%s\n",ename);
exit(0);
}
Received on Mon Aug 26 1996 - 00:00:00 CEST