Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: C, CGI, and Oracle
The missing letters are OCI. Presuming you are interested in V7 OCI
here is a sample from NT, (shouldn't matter). The reference is the
Programmers Guide to the Oracle Call Interface:
#include <stdio.h> #include <string.h> #include <malloc.h> #include
<ociapr.h>
#pragma comment(lib, "d:\\orant\\oci73\\lib\\old\\ora73.lib")
#define VARCHAR2_TYPE 1 #define NUMBER_TYPE 2
#define INT_TYPE 3 #define FLOAT_TYPE 4
#define STRING_TYPE 5 #define ROWID_TYPE 11
#define DATE_TYPE 12
#define ECODE printf("Routine #%i failed with Oracle error
%i\n",cda.fc,cda.rc);
Lda_Def lda; Cda_Def cda; ub1 hda[256]; char* v_loc; char*
v_dname;
int v_deptno;short i_loc;short i_dname;short
i_deptno; void main() { v_loc = (char*)malloc(30); strcpy(v_loc,"MONTREAL"); v_dname = (char*)malloc(30); strcpy(v_dname,"SHIPPING"); v_deptno = 50;
printf("Logon failed: %i\n", lda.rc); if (oopen(&cda,&lda,0,-1,-1,0,-1)) printf("Open failed: %i\n", lda.rc);
&i_deptno,0,0,0,0,0,-1,-1)) ECODE
if (obndra(&cda,":dname",-1,v_dname,30,STRING_TYPE,-1,
&i_dname,0,0,0,0,0,-1,-1)) ECODE
if (obndra(&cda,":loc",-1,v_loc,30,STRING_TYPE,-1,
&i_loc,0,0,0,0,0,-1,-1)) ECODE
if (oexec(&cda)) ECODE if (ocan(&cda)) ECODE if (ocom(&lda)) printf("Commit failed: %i\n", cda.rc);strcpy(v_dname,"EXPEDITION");
if (oexec(&cda)) ECODE if (ocan(&cda)) ECODE if (ocom(&lda)) printf("Commit failed: %i\n", cda.rc); v_deptno = 30;if (oparse(&cda,"select deptno, dname, loc from dept where deptno < :deptno",-1,1,2)) ECODE
0,0,0,0,0,0,-1,-1)) ECODE
if (odefin(&cda,1,(char*)&v_deptno,sizeof(int),INT_TYPE,
-1,0,0,-1,-1,0,0)) ECODE
if (odefin(&cda,2,v_dname,12,STRING_TYPE,-1,0,0,-1,-1,0,0)) ECODE if (odefin(&cda,3,v_loc,12,STRING_TYPE,-1,0,0,-1,-1,0,0)) ECODE if (oexfet(&cda,1,0,0)) ECODE printf("\n%i", v_deptno); printf("\n%s", v_dname); printf("\n%s\n", v_loc); if (ofetch(&cda)) ECODE printf("\n%i", v_deptno); printf("\n%s", v_dname); printf("\n%s\n", v_loc);