1、10gR2的server端安装是否已经默认安装了proc?
答:是的,也就意味着不用再通过client端安装包再装一遍Precompilers了。
2、为什么找不到demo_proc.mk?
答:默认安装不会有demo_proc.mk。10g里demo_proc.mk在Companion CD里,11g里demo_proc.mk在Example CD里。demo_proc.mk随便拷一个拿来就能用了,比如我的demo_proc.mk就是找熊哥要的。
我们来看一个最简单的proc的例子:
$ pwd
/u01/app/oracle/product/
$ ls
demo_proc.mk demo_proc64.mk sample1.pc
sample1.pc的目的是把ipratest中表emp中指定记录给print出来。
SQL> conn scott/tiger@ipratest;
Connected to Oracle Database
Connected as scott
SQL> select empno,ename,sal,comm from emp where ename in ('SMITH','CUIHUA');
EMPNO ENAME SAL COMM
----- ---------- --------- ---------
7369 SMITH 1000.00
7499 CUIHUA 1600.00 300.00
现在我们把sample1.pc编译成可执行文件并把上述两条记录给print出来:
$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib
$ export OBJECT_MODE=64
$ make -f demo_proc.mk sample1 PROCFLAGS="userid=scott/tiger@ipratest"
/bin/make -f /u01/app/oracle/product/
proc userid=scott/tiger@ipratest iname=sample1 include=. include=/u01/app/oracle/product/
Pro*C/C++: Release
Copyright (c) 1982, 2007, Oracle. All rights reserved.
System default option values taken from: /u01/app/oracle/product/
/bin/make -f /u01/app/oracle/product/
/u01/app/oracle/product/
"sample1.c", line 157.2: 1506-218 (E) Unknown preprocessing directive #incluee.
"sample1.c", line 295.1: 1506-412 (I) Referenced variable "sqlstm", which was not initialized in its declaration.
"sample1.c", line 381.1: 1506-412 (I) Referenced variable "sqlstm", which was not initialized in its declaration.
"sample1.c", line 422.1: 1506-412 (I) Referenced variable "sqlstm", which was not initialized in its declaration.
"sample1.c", line 426.1: 1506-412 (I) Referenced variable "temp_char", which was not initialized in its declaration.
"sample1.c", line 456.1: 1506-412 (I) Referenced variable "sqlstm", which was not initialized in its declaration.
"sample1.c", line 460.1: 1506-412 (I) Referenced variable "msg_len", which was not initialized in its declaration.
"sample1.c", line 460.1: 1506-412 (I) Referenced variable "buf_len", which was not initialized in its declaration.
"sample1.c", line 460.1: 1506-412 (I) Referenced variable "err_msg", which was not initialized in its declaration.
/u01/app/oracle/product/
$ ls
demo_proc.mk demo_proc64.mk sample1 sample1.c sample1.lis sample1.o sample1.pc
$ ./sample1
Connected to ORACLE as user: SCOTT
Enter employee number (0 to quit): 7369
Employee Salary Commission
-------- ------ ----------
SMITH 1000.00 0.00
Enter employee number (0 to quit): 7499
Employee Salary Commission
-------- ------ ----------
CUIHUA 1600.00 300.00
Enter employee number (0 to quit): 0
Total rows returned was 2.
G'day.
最后我们来看一下pcscfg.cfg的内容:
$ cat /u01/app/oracle/product/
sys_include=(/usr/include)
ltype=short
code=ansi_c
cpp_suffix=cc
parse=none
SQLCHECK=SEMANTICS
Leave a comment