Proc example Write by okcai2004-6-18 13:53
Environment: HP 9000 Software: HP-UX B.11.111 Modify ProC Default Profile Include: The directory path of the file is generally configured in the config file, and the default definition in PCSCFG.cfg is available. SYS_INCLUDE: The directory where the system header file is located, which is generally configured in the config file, and the default definition in the PCSCFG.cfg is available. But pay attention to the path of the default system header file is not right. Such as sys_include = ($ oracle_home / precomp / public, / usr / include, / usr / lib / gcc-lib / i386-redhat-linux / eGCS-2.91.66 / incrude) user ID: User Name / Password [@dbname] connection string
The pcscfg.cfg file is SYS_INCLUDE = (/ us) LTYPE = shortdefine = ORASTDARG
$ Oracle_home / precomp / admin / pcscfg.cfg
1. Write an example code CAI.pc, the function is the name of the mobile phone number 13905718888
#include
EXEC SQL include Sqlca; Exec Oracle Option; Exec SQL Begin Declare Section; Char VNAME [30]; char vPass [30]; char vsvr [30]; char vcustname [60]; exec SQL END DECLARE Section;
#ifdef __cplusplusextern "C" #ENDIFVOID #if Defined (__ stdc__) || defined (__ cplusplus) SQL_ERROR (Char * MSG) #LSESQL_ERROR (MSG) char * msg; #ENDIF {Printf ("/ N% s,% ld,% s / n ", msg, sqlca.sqlcode, (char *) sqlca.sqlerrm.sqlerrmc); Exec SQL ROLLBACK Release; EXIT (-1);
#ifdef __cplusplusextern "C" #ENDIFINTMAIN () {EXEC SQL WHENEVER SQLEROR DO SQL_ERROR ("Oracle Error:");
STRCPY (VNAME, "AICBS"); STRCPY (VPass, "AICBS"); STRCPY (VSVR, "Busi_CS"); Printf ("Start Connect To Database% S /% S @% S / N", VNAME, VPAS, vSvr); EXEC SQL CONNECT: vName IDENTIFIED BY: vPass USING: vSvr; EXEC SQL SELECT CUST_NAME INTO: vCustName FROM CM_CUSTOMER WHERE CUST_ID = (SELECT / CUST_ID FROM CM_USER WHERE BILL_ID = '13905718888'); printf ( "The Result of select, Cust_name =% s / n ", vcustname); Return 0;} 2. Precatch
Proc cai.pc
3. Compile, link (compilation environment is HP UNIX, other operating system -L connection dynamic library needs to be modified) CC cai.c -i $ oracle_home / precomp / public -l $ oracle_home / precomp / lib32 -l $ oracle_home / lib32 -LCLNTSH
4. If written as Makefilecai: cai.pc proc cai.pc cc cai.c -i $ (oracle_home) / precomp / public -l $ (oracle_home) / precomp / lib32 -l $ (oracle_home) / lib32 -lclntsh -o CAI