PRO C to connect oracle and C
Unix C++ :: UNIX CPP :: CPP :: Case Studies
Page 1 of 1
PRO C to connect oracle and C
a code using PRO *C to connect oracle and cpp!
include the include u want!
to use c++ use the cin and cout~
now to compile this we need to save this file using .pc extension ( sampleproc.pc)
then we to compile using PROC command
PROC sampleproc.pc
then we will get a output with .c extension then i dont know if to compile the .c file directly using g++ compiler or have to link some library headers!!!!!
help out ppl!
include the include u want!
to use c++ use the cin and cout~
- Code:
/* program to change the salary of an employee */
#include
#include
#include
#include
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR uid[80];
VARCHAR pwd[20];
int empno;
int sal;
VARCHAR ename[30];
int newsal;
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA.H;
void main()
{
strcpy(uid.arr,"SCOTT");
uid.len =strlen(uid.arr);
strcpy(pwd.arr,"TIGER");
pwd.len = strlen(pwd.arr);
EXEC SQL WHENEVER SQLERROR GOTO errexit;
EXEC SQL CONNECT :uid IDENTIFIED BY :pwd;
/* take employee number from user */
printf("Enter employee number : ");
scanf("%d",&empno);
/* get the details of the employee */
EXEC SQL WHENEVER NOTFOUND GOTO noemp;
EXEC SQL select ename, sal into :ename, :sal from emp where empno = :empno;
/* display employee name and salary */
ename.arr [ ename.len ] = '\0';
printf("Name : %s Salary : %d\n", ename.arr, sal);
printf("Enter new salary : ");
scanf("%d", &newsal);
/* update employee record */
EXEC SQL update emp set sal = :newsal where empno = :empno;
printf("Updation Successful");
goto normalexit;
noemp:
printf("Sorry. Invalid employee number. Quitting...");
normalexit:
EXEC SQL COMMIT WORK RELEASE;
return;
errexit:
printf("Error: %70s", sqlca.sqlerrm.sqlerrmc);
}
now to compile this we need to save this file using .pc extension ( sampleproc.pc)
then we to compile using PROC command
PROC sampleproc.pc
then we will get a output with .c extension then i dont know if to compile the .c file directly using g++ compiler or have to link some library headers!!!!!
help out ppl!
Unix C++ :: UNIX CPP :: CPP :: Case Studies
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|