Re: OCI vs. Pro*C
Date: Tue, 11 Jan 1994 22:17:57 GMT
Message-ID: <STEFOL.94Jan11171757_at_u30004.rsv.svskt.se>
In article <36131_at_mindlink.bc.ca> Bruce_MacDonald_at_mindlink.bc.ca (Bruce MacDonald) writes:
> Why would you NOT want to use Pro*C? The OCI calls are quite low-level.
> Using Pro*C just saves a lot of grunt work.
But you also have problems debugging your program, since debuggers generally work on the c code rather than the pc code. Also that the effects of "exec sql on sqlerror goto label" in one procedure also remains in subsequent procedures can be a bit surprising. Another thing is that there are some tricky ordering rules when you deal with several db connections at the same time, as well as you sometimes have to duplicate source code for each db connection you use.
I thought the oraperl way (by Kevin Stock) was very nice, so I extracted the oracle functions and just added a c interface with a bit of perl taste. Below is an example that shows most of the interfaces.
#include <stdio.h>
#include <orac.h>
main()
{
DATABASE *lda;
CURSOR *csr;
int atrc;
char **atrv;
if(!(lda=ora_login(getenv("ORACLE_SID"),"scott","tiger"))) {
fprintf(stderr,"Login %s\n",ora_errstr()); exit(1);
}
if(!(csr=ora_open(lda,
"select name,telno from phonelist order by name"))) { fprintf(stderr,"Open %s\n",ora_errstr()); exit(1);
}
while (ora_fetch(csr,&atrc,&atrv))
printf("Name: %s Telno: %s\n",atrv[0],atrv[1]); if(ora_errno) {
fprintf(stderr,"Fetch %s\n",ora_errstr()); exit(1);
}
if(!(ora_close(csr))) {
fprintf(stderr,"Close %s\n",ora_errstr()); exit(1);
}
if(!(ora_logoff(lda))) {
fprintf(stderr,"Logoff %s\n",ora_errstr()); exit(1);
}
exit(0);
} Received on Tue Jan 11 1994 - 23:17:57 CET