使proc预编译命令可用:
[karihou@bogon ~]$ cat ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH export ORACLE_BASE=/home/karihou/app/karihou export ORACLE_HOME=/home/karihou/app/karihou/product/11.2.0/dbhome_1 export ORACLE_SID=orcl export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:$LD_LIBRARY_PATH
配置pcscfg.cfg文件:
[karihou@bogon admin]$ view pcscfg.cfg sys_include=($ORACLE_HOME/precomp/public,/usr/include,/usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/include,/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include,/usr/lib64/gcc/x86_64-suse-linux/4.1.2/include,/usr/lib64/gcc/x86_64-suse-linux/4.3/include,/usr/lib/gcc/x86_64-redhat-linux/4.4.4/include) ltype=short define=__x86_64__ #以下为手动添加环境变量 include=($ORACLE_HOME/precomp/public) include=$ORACLE_HOME/precomp/hdrs include=$ORACLE_HOME/tpcc2x_2/src include=$ORACLE_HOME/precomp/precomp/include include=$ORACLE_HOME/precomp/oracore/include include=$ORACLE_HOME/precomp/oracore/public include=$ORACLE_HOME/precomp/rdbms/include include=$ORACLE_HOME/precomp/rdbms/public include=$ORACLE_HOME/precomp/rdbms/demo include=$ORACLE_HOME/precomp/nlsrtl/include include=$ORACLE_HOME/precomp/nlsrtl/public include=$ORACLE_HOME/precomp/network_src/include include=$ORACLE_HOME/precomp/network_src/public include=$ORACLE_HOME/precomp/network/include include=$ORACLE_HOME/precomp/network/public include=$ORACLE_HOME/precomp/plsql/public ltype=short
测试源码:
[root@bogon ~]$ cat login.pc #include <stdio.h> #include <stdlib.h> #include <string.h> EXEC SQL INCLUDE sqlca; EXEC SQL BEGIN DECLARE SECTION; varchar username[20]; varchar password[20]; EXEC SQL END DECLARE SECTION; int main(void) { strcpy(username.arr, "karihou"); username.len = strlen("karihou"); strcpy(password.arr, "1"); password.len = strlen("1"); EXEC SQL CONNECT :username IDENTIFIED BY :password; if(sqlca.sqlcode == 0){ printf("login success "); }else{ printf("login failed "); } exit(0); }