主要功能是:程序提示用户输入 部门号,然后显示该部门的名字,地址及职员人数。
Pro*C中 samplePL_SQL.pc 代码如下:
在这里要注意得是
exec sql execute
begin
.....
end;
end-exec; -->这个地方千要注意,不能写能 end_exec,这样会出错。
我遇到下面错误:
PCC-S-02022, Found end of file while scanning a SQL statement
将end_exec 改为 end-exec 这个错误就好了。
相应的表:
create table xtn_dept
(
deptno number(8) not null,
dname varchar2(40) default '部门名称',
loc varchar2(40) default '本地location',
cdate date default sysdate,
dnumber number(8) default '0'
);
makefile:
1 include ${ORACLE_HOME}/rdbms/lib/env_rdbms.mk
2 ORAINC=${ORACLE_HOME}/precomp/public
3 ORALIB=${ORACLE_HOME}/lib
4 ORAPUBLIC=${ORACLE_HOME}/rdbms/public
5
6 PROC = proc
7 PROCINFO = /
8 userid=scdb/scdb /
9 include=$(ORAINC) /
10 include=$(ORAPUBLIC) /
11 lines=true /
12 parse=full /
13 sqlCheck=semantics
14
15 CC = gcc -ggdb3 -Wall
16
17 CFLAGS = -I $(ORAINC) -I $(ORAPUBLIC)
98 obj_PL_SQL = samplePL_SQL.o
99 samplePL_SQL:$(obj_PL_SQL)
100 $(CC) $(CFLAGS) $(obj_PL_SQL) -o samplePL_SQL -L $(ORALIB) $(PROLDLIBS) -lm
101 samplePL_SQL.c:samplePL_SQL.pc
102 $(PROC) $(PROCINFO) INAME=samplePL_SQL.pc ONAME=samplePL_SQL.c
103
104 .PHONY:clean
105 clean:
106 rm -f samplePL_SQL *.o *.c