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

Home -> Community -> Usenet -> c.d.o.misc -> Re: C, CGI, and Oracle

Re: C, CGI, and Oracle

From: mark tomlinson <marktoml_at_gdi.net>
Date: Thu, 09 Apr 1998 18:51:14 GMT
Message-ID: <352e1772.19282366@newshost.us.oracle.com>


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;

if(olog(&lda,hda,(text*)"scott/tiger_at_t:orlnt-5:ORCL",-1,0,-1,0,-1,OCI_LM_DEF))
printf("Logon failed: %i\n", lda.rc);  	if
(oopen(&cda,&lda,0,-1,-1,0,-1)) 
printf("Open failed: %i\n", lda.rc);  

if (oparse(&cda,"insert into dept values (:deptno, :dname, :loc)",-1,1,2)) ECODE
if (obndra(&cda,":deptno",-1,(char*)&v_deptno,sizeof(int),INT_TYPE,-1,

&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 (oparse(&cda,"update dept set dname = :dname where deptno = 50",-1,1,2)) ECODE
if (obndra(&cda,":dname",-1,v_dname,30,STRING_TYPE,-1, &i_dname,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); 	v_deptno = 30;
if (oparse(&cda,"select deptno, dname, loc from dept where deptno < :deptno",-1,1,2)) ECODE
if (obndra(&cda,":deptno",-1,(char*)&v_deptno,sizeof(int),INT_TYPE,-1,

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); 

if (oclose(&cda)) ECODE
if (ologof(&lda))
printf("Logoff failed: %i\n", lda.rc); return; } Received on Thu Apr 09 1998 - 13:51:14 CDT

Original text of this message

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