大家好,我是刚学习Oracle的,学习过程中用到一个给一个数据表写过程,然后我引用了书上提供的过程代码,结果 提示:创建的过程带有编译错误!请大家帮忙看下,能解决的话帮我解决下,先在这里谢谢了!/*定义过程参数*/
create or replace procedure scott.graduateprocess(
tempzhengzhi in scott.graduate.zhengzhi%type,
tempyingyu in scott.graduate.yingyu%type,
tempzhuanye1 in scott.graduate.zhuanye1%type,
tempzhuanye2 in scott.graduate.zhuanye2%type,
tempzhuanye3 in scott.graduate.zhuanye3%type,
temptotalscore in scott.result.totalscore%type) as
/*定义graduaterecord为记录型变量,临时存放通过游标从graduate数据表中提取的记录*/
graduaterecord scott.graduate%rowtype;
/*定义graduatetotalscore为数值型变量,统计总分*/
graduatetotalscore scott.result.totalscore%type;
/*定义graduateflag为字符型变量,根据结果放入“落选”或“录取”,然后写入数据表result*/
graduateflag varchar2(4);
/*定义游标graduatecursor,存放的是所有的graduate数据表中的记录*/
cursor graduatecursor is
select * from scott.graduate;
/*定义异常处理errormessage*/
errormessage exception;
/*开始执行*/
begin
/*打开游标*/
open graduatecursor;
/*如果游标没有数据,激活异常处理*/
if graduatecursor%notfound then
raise errormessage;
end if;
/*游标有数据,指针指向第一条记录,每执行fetch命令,就自动下移,循环执行到记录提取完毕为止*/
loop
fetch graduatecursor into graduaterecord;
/*计算总分*/
graduatetotalscore:=graduaterecord.yingyu+graduaterecord.zhengzhi+graduaterecord.zhuanye1+graduaterecord.zhuanye2+graduaterecord.zhuanye3;
/*判断单科和总分是否满足录取要求,若满足,graduateflag变量值为“录取”,否则为“落选”*/
if (graduaterecord.yingyu>=tempyingyu and
graduaterecord.zhengzhi>=tempzhengzhi and
graduaterecord.zhuanye1>=tempzhuanye1 and
graduaterecord.zhuanye2>=tempzhuanye2 and
graduaterecord.zhuanye3>=tempzhuanye3 and
graduatetotalscore>=temptotalscore) then
graduateflag:='录取';
else
graduateflag:='落选';
end if;
/*当游标数据提取完毕后,退出循环”*/
exit when graduatecursor%notfound;
/*向结果数据表result中插入处理后的数据*/
insert into scott.result(bh,xm,lb,zhengzhi,yingyu,zhuanye1,zhuanye2,zhuanye3,totalscore,flag) values(graduaterecord.bh,graduaterecord.xm,graduaterecord.lb,graduaterecord.zhengzhi,graduaterecord.yingyu,graduaterecord.zhuanye1,graduaterecord.zhuanye2,graduaterecord.zhuanye3,graduatetotalscore,graduateflag);
end loop;
/*关闭游标*/
close graduatecursor;
/*提交结果*/
commit;
/*异常处理,提示错误信息*/
exception
when errormessage then
dbms_output.put_line('无法打开数据表');
/*程序执行结束”*/
end;
create or replace procedure scott.graduateprocess(
tempzhengzhi in scott.graduate.zhengzhi%type,
tempyingyu in scott.graduate.yingyu%type,
tempzhuanye1 in scott.graduate.zhuanye1%type,
tempzhuanye2 in scott.graduate.zhuanye2%type,
tempzhuanye3 in scott.graduate.zhuanye3%type,
temptotalscore in scott.result.totalscore%type) as
/*定义graduaterecord为记录型变量,临时存放通过游标从graduate数据表中提取的记录*/
graduaterecord scott.graduate%rowtype;
/*定义graduatetotalscore为数值型变量,统计总分*/
graduatetotalscore scott.result.totalscore%type;
/*定义graduateflag为字符型变量,根据结果放入“落选”或“录取”,然后写入数据表result*/
graduateflag varchar2(4);
/*定义游标graduatecursor,存放的是所有的graduate数据表中的记录*/
cursor graduatecursor is
select * from scott.graduate;
/*定义异常处理errormessage*/
errormessage exception;
/*开始执行*/
begin
/*打开游标*/
open graduatecursor;
/*如果游标没有数据,激活异常处理*/
if graduatecursor%notfound then
raise errormessage;
end if;
/*游标有数据,指针指向第一条记录,每执行fetch命令,就自动下移,循环执行到记录提取完毕为止*/
loop
fetch graduatecursor into graduaterecord;
/*计算总分*/
graduatetotalscore:=graduaterecord.yingyu+graduaterecord.zhengzhi+graduaterecord.zhuanye1+graduaterecord.zhuanye2+graduaterecord.zhuanye3;
/*判断单科和总分是否满足录取要求,若满足,graduateflag变量值为“录取”,否则为“落选”*/
if (graduaterecord.yingyu>=tempyingyu and
graduaterecord.zhengzhi>=tempzhengzhi and
graduaterecord.zhuanye1>=tempzhuanye1 and
graduaterecord.zhuanye2>=tempzhuanye2 and
graduaterecord.zhuanye3>=tempzhuanye3 and
graduatetotalscore>=temptotalscore) then
graduateflag:='录取';
else
graduateflag:='落选';
end if;
/*当游标数据提取完毕后,退出循环”*/
exit when graduatecursor%notfound;
/*向结果数据表result中插入处理后的数据*/
insert into scott.result(bh,xm,lb,zhengzhi,yingyu,zhuanye1,zhuanye2,zhuanye3,totalscore,flag) values(graduaterecord.bh,graduaterecord.xm,graduaterecord.lb,graduaterecord.zhengzhi,graduaterecord.yingyu,graduaterecord.zhuanye1,graduaterecord.zhuanye2,graduaterecord.zhuanye3,graduatetotalscore,graduateflag);
end loop;
/*关闭游标*/
close graduatecursor;
/*提交结果*/
commit;
/*异常处理,提示错误信息*/
exception
when errormessage then
dbms_output.put_line('无法打开数据表');
/*程序执行结束”*/
end;
解决方案 »
- 修改5W条数据,求解决方法,谢谢
- IMP-00041 Warning: object created with compilation warnings
- Oracle存储空间创建问题
- 把数据导入到oracle一个已存在的表,如何操作?
- 一个编程问题
- 100%送分!!!非常简单的问题:连接ORACLE 数据库问题++++++++++++++++++++++++++++++++++
- [急问,在线等]oracle崩溃了,根据日志能看出是什么原因吗?
- 求C#.net上传图片到Oracle数据库及显示图片代码
- 请教作业不自动执行和spfile(sid).ora文件不能更改的问题?
- 初学问题
- oracle 9i 求段sql
- 怎样查看我自己建的表的名称
在添加下!
大家好,我是刚学习Oracle的,学习过程中用到一个给一个数据表写过程,然后我引用了书上提供的过程代码,结果 提示:创建的过程带有编译错误!请大家帮忙看下,能解决的话帮我解决下,先在这里谢谢了![code=SQL]/*定义过程参数*/
create or replace procedure scott.graduateprocess(
tempzhengzhi in scott.graduate.zhengzhi%type,
tempyingyu in scott.graduate.yingyu%type,
tempzhuanye1 in scott.graduate.zhuanye1%type,
tempzhuanye2 in scott.graduate.zhuanye2%type,
tempzhuanye3 in scott.graduate.zhuanye3%type,
temptotalscore in scott.result.totalscore%type) as
/*定义graduaterecord为记录型变量,临时存放通过游标从graduate数据表中提取的记录*/
graduaterecord scott.graduate%rowtype;
/*定义graduatetotalscore为数值型变量,统计总分*/
graduatetotalscore scott.result.totalscore%type;
/*定义graduateflag为字符型变量,根据结果放入“落选”或“录取”,然后写入数据表result*/
graduateflag varchar2(4);
/*定义游标graduatecursor,存放的是所有的graduate数据表中的记录*/
cursor graduatecursor is
select * from scott.graduate;
/*定义异常处理errormessage*/
errormessage exception;
/*开始执行*/
begin
/*打开游标*/
open graduatecursor;
/*如果游标没有数据,激活异常处理*/
if graduatecursor%notfound then
raise errormessage;
end if;
/*游标有数据,指针指向第一条记录,每执行fetch命令,就自动下移,循环执行到记录提取完毕为止*/
loop
fetch graduatecursor into graduaterecord;
/*计算总分*/
graduatetotalscore:=graduaterecord.yingyu+graduaterecord.zhengzhi+graduaterecord.zhuanye1+graduaterecord.zhuanye2+graduaterecord.zhuanye3;
/*判断单科和总分是否满足录取要求,若满足,graduateflag变量值为“录取”,否则为“落选”*/
if (graduaterecord.yingyu>=tempyingyu and
graduaterecord.zhengzhi>=tempzhengzhi and
graduaterecord.zhuanye1>=tempzhuanye1 and
graduaterecord.zhuanye2>=tempzhuanye2 and
graduaterecord.zhuanye3>=tempzhuanye3 and
graduatetotalscore>=temptotalscore) then
graduateflag:='录取';
else
graduateflag:='落选';
end if;
/*当游标数据提取完毕后,退出循环”*/
exit when graduatecursor%notfound;
/*向结果数据表result中插入处理后的数据*/
insert into scott.result(bh,xm,lb,zhengzhi,yingyu,zhuanye1,zhuanye2,zhuanye3,totalscore,flag) values(graduaterecord.bh,graduaterecord.xm,graduaterecord.lb,graduaterecord.zhengzhi,graduaterecord.yingyu,graduaterecord.zhuanye1,graduaterecord.zhuanye2,graduaterecord.zhuanye3,graduatetotalscore,graduateflag);
end loop;
/*关闭游标*/
close graduatecursor;
/*提交结果*/
commit;
/*异常处理,提示错误信息*/
exception
when errormessage then
dbms_output.put_line('无法打开数据表');
/*程序执行结束”*/
end;
[/code]
create or replace procedure scott.graduateprocess(
tempzhengzhi in scott.graduate.zhengzhi%type,
tempyingyu in scott.graduate.yingyu%type,
tempzhuanye1 in scott.graduate.zhuanye1%type,
tempzhuanye2 in scott.graduate.zhuanye2%type,
tempzhuanye3 in scott.graduate.zhuanye3%type,
temptotalscore in scott.result.totalscore%type) as
/*定义graduaterecord为记录型变量,临时存放通过游标从graduate数据表中提取的记录*/
graduaterecord scott.graduate%rowtype;
/*定义graduatetotalscore为数值型变量,统计总分*/
graduatetotalscore scott.result.totalscore%type;
/*定义graduateflag为字符型变量,根据结果放入“落选”或“录取”,然后写入数据表result*/
graduateflag varchar2(4);
/*定义游标graduatecursor,存放的是所有的graduate数据表中的记录*/
cursor graduatecursor is
select * from scott.graduate;
/*定义异常处理errormessage*/
errormessage exception;
/*开始执行*/
begin
/*打开游标*/
open graduatecursor;
/*如果游标没有数据,激活异常处理*/
if graduatecursor%notfound then
raise errormessage;
end if;
/*游标有数据,指针指向第一条记录,每执行fetch命令,就自动下移,循环执行到记录提取完毕为止*/
loop
fetch graduatecursor into graduaterecord;
/*计算总分*/
graduatetotalscore:=graduaterecord.yingyu+graduaterecord.zhengzhi+graduaterecord.zhuanye1+graduaterecord.zhuanye2+graduaterecord.zhuanye3;
/*判断单科和总分是否满足录取要求,若满足,graduateflag变量值为“录取”,否则为“落选”*/
if (graduaterecord.yingyu>=tempyingyu and
graduaterecord.zhengzhi>=tempzhengzhi and
graduaterecord.zhuanye1>=tempzhuanye1 and
graduaterecord.zhuanye2>=tempzhuanye2 and
graduaterecord.zhuanye3>=tempzhuanye3 and
graduatetotalscore>=temptotalscore) then
graduateflag:='录取';
else
graduateflag:='落选';
end if;
/*当游标数据提取完毕后,退出循环”*/
exit when graduatecursor%notfound;
/*向结果数据表result中插入处理后的数据*/
insert into scott.result(bh,xm,lb,zhengzhi,yingyu,zhuanye1,zhuanye2,zhuanye3,totalscore,flag) values(graduaterecord.bh,graduaterecord.xm,graduaterecord.lb,graduaterecord.zhengzhi,graduaterecord.yingyu,graduaterecord.zhuanye1,graduaterecord.zhuanye2,graduaterecord.zhuanye3,graduatetotalscore,graduateflag);
end loop;
/*关闭游标*/
close graduatecursor;
/*提交结果*/
commit;
/*异常处理,提示错误信息*/
exception
when errormessage then
dbms_output.put_line('无法打开数据表');
/*程序执行结束”*/
end;
[/code]
create or replace procedure scott.graduateprocess(
tempzhengzhi in scott.graduate.zhengzhi%type,
tempyingyu in scott.graduate.yingyu%type,
tempzhuanye1 in scott.graduate.zhuanye1%type,
tempzhuanye2 in scott.graduate.zhuanye2%type,
tempzhuanye3 in scott.graduate.zhuanye3%type,
temptotalscore in scott.result.totalscore%type) as
/*定义graduaterecord为记录型变量,临时存放通过游标从graduate数据表中提取的记录*/
graduaterecord scott.graduate%rowtype;
/*定义graduatetotalscore为数值型变量,统计总分*/
graduatetotalscore scott.result.totalscore%type;
/*定义graduateflag为字符型变量,根据结果放入“落选”或“录取”,然后写入数据表result*/
graduateflag varchar2(4);
/*定义游标graduatecursor,存放的是所有的graduate数据表中的记录*/
cursor graduatecursor is
select * from scott.graduate;
/*定义异常处理errormessage*/
errormessage exception;
/*开始执行*/
begin
/*打开游标*/
open graduatecursor;
/*如果游标没有数据,激活异常处理*/
if graduatecursor%notfound then
raise errormessage;
end if;
/*游标有数据,指针指向第一条记录,每执行fetch命令,就自动下移,循环执行到记录提取完毕为止*/
loop
fetch graduatecursor into graduaterecord;
/*计算总分*/
graduatetotalscore:=graduaterecord.yingyu+graduaterecord.zhengzhi+graduaterecord.zhuanye1+graduaterecord.zhuanye2+graduaterecord.zhuanye3;
/*判断单科和总分是否满足录取要求,若满足,graduateflag变量值为“录取”,否则为“落选”*/
if (graduaterecord.yingyu>=tempyingyu and
graduaterecord.zhengzhi>=tempzhengzhi and
graduaterecord.zhuanye1>=tempzhuanye1 and
graduaterecord.zhuanye2>=tempzhuanye2 and
graduaterecord.zhuanye3>=tempzhuanye3 and
graduatetotalscore>=temptotalscore) then
graduateflag:='录取';
else
graduateflag:='落选';
end if;
/*当游标数据提取完毕后,退出循环”*/
exit when graduatecursor%notfound;
/*向结果数据表result中插入处理后的数据*/
insert into scott.result(bh,xm,lb,zhengzhi,yingyu,zhuanye1,zhuanye2,zhuanye3,totalscore,flag) values(graduaterecord.bh,graduaterecord.xm,graduaterecord.lb,graduaterecord.zhengzhi,graduaterecord.yingyu,graduaterecord.zhuanye1,graduaterecord.zhuanye2,graduaterecord.zhuanye3,graduatetotalscore,graduateflag);
end loop;
/*关闭游标*/
close graduatecursor;
/*提交结果*/
commit;
/*异常处理,提示错误信息*/
exception
when errormessage then
dbms_output.put_line('无法打开数据表');
/*程序执行结束”*/
end;
CREATE TABLE "SCOTT"."GRADUATE" (
"BH" NUMBER(10) NOT NULL,
"XM" VARCHAR2(10) NOT NULL,
"LB" VARCHAR2(10) NOT NULL,
"YINGYU" NUMBER(4, 1) NOT NULL,
"ZHENGZHI" NUMBER(4, 1) NOT NULL,
"ZHUANYE1" NUMBER(4, 1) NOT NULL,
"ZHUANYE2" NUMBER(4, 1) NOT NULL,
"ZHUANYE3" NUMBER(4, 1) NOT NULL)
TABLESPACE "USERS"数据表SCOTT.RESULT的创建代码:
CREATE TABLE "SCOTT"."RESULT" (
"BH" NUMBER(10) NOT NULL,
"XM" VARCHAR2(10) NOT NULL,
"LB" VARCHAR2(10) NOT NULL,
"YINGYU" NUMBER(4, 1) NOT NULL,
"ZHENGZHI" NUMBER(4, 1) NOT NULL,
"ZHUANYE1" NUMBER(4, 1) NOT NULL,
"ZHUANYE2" NUMBER(4, 1) NOT NULL,
"ZHUANYE3" NUMBER(4, 1) NOT NULL,
"TOTALSCORE" NUMBER(5, 1) NOT NULL,
"FLAG" VARCHAR2(4) NOT NULL)
TABLESPACE "USERS" 数据表SCOTT.GRADUATE的内容添加代码:INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003080520 ,'张三丰' ,'硕士' ,55 ,56 ,67 ,78 ,89 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003060555 ,'张翠山' ,'硕士' ,66 ,78 ,78 ,89 ,92 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003056066 ,'张无忌' ,'硕士' ,76 ,67 ,89 ,90 ,66 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003010989 ,'赵敏' ,'硕士' ,45 ,59 ,74 ,66 ,56 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003050677 ,'周芷若' ,'硕士' ,77 ,67 ,72 ,87 ,66 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003869401 ,'小昭' ,'硕士' ,56 ,67 ,56 ,64 ,34 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003340987 ,'阿离' ,'硕士' ,68 ,93 ,64 ,80 ,56 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003056709 ,'宋远桥' ,'硕士' ,90 ,68 ,81 ,61 ,67 );
INSERT INTO "SCOTT"."GRADUATE" ("BH" ,"XM" ,"LB" ,"YINGYU" ,"ZHENGZHI" ,"ZHUANYE1" ,"ZHUANYE2" ,"ZHUANYE3" ) VALUES (2003100894 ,'殷素素' ,'硕士' ,69 ,73 ,62 ,70 ,75 );就是这些数据,
然后执行上面一开始发出的过程,过程代码如下:
/*定义过程参数*/
create or replace procedure scott.graduateprocess(
tempzhengzhi in scott.graduate.zhengzhi%type,
tempyingyu in scott.graduate.yingyu%type,
tempzhuanye1 in scott.graduate.zhuanye1%type,
tempzhuanye2 in scott.graduate.zhuanye2%type,
tempzhuanye3 in scott.graduate.zhuanye3%type,
temptotalscore in scott.result.totalscore%type) as
/*定义graduaterecord为记录型变量,临时存放通过游标从graduate数据表中提取的记录*/
graduaterecord scott.graduate%rowtype;
/*定义graduatetotalscore为数值型变量,统计总分*/
graduatetotalscore scott.result.totalscore%type;
/*定义graduateflag为字符型变量,根据结果放入“落选”或“录取”,然后写入数据表result*/
graduateflag varchar2(4);
/*定义游标graduatecursor,存放的是所有的graduate数据表中的记录*/
cursor graduatecursor is
select * from scott.graduate;
/*定义异常处理errormessage*/
errormessage exception;
/*开始执行*/
begin
/*打开游标*/
open graduatecursor;
/*如果游标没有数据,激活异常处理*/
if graduatecursor%notfound then
raise errormessage;
end if;
/*游标有数据,指针指向第一条记录,每执行fetch命令,就自动下移,循环执行到记录提取完毕为止*/
loop
fetch graduatecursor into graduaterecord;
/*计算总分*/
graduatetotalscore:=graduaterecord.yingyu+graduaterecord.zhengzhi+graduaterecord.zhuanye1+graduaterecord.zhuanye2+graduaterecord.zhuanye3;
/*判断单科和总分是否满足录取要求,若满足,graduateflag变量值为“录取”,否则为“落选”*/
if (graduaterecord.yingyu>=tempyingyu and
graduaterecord.zhengzhi>=tempzhengzhi and
graduaterecord.zhuanye1>=tempzhuanye1 and
graduaterecord.zhuanye2>=tempzhuanye2 and
graduaterecord.zhuanye3>=tempzhuanye3 and
graduatetotalscore>=temptotalscore) then
graduateflag:='录取';
else
graduateflag:='落选';
end if;
/*当游标数据提取完毕后,退出循环”*/
exit when graduatecursor%notfound;
/*向结果数据表result中插入处理后的数据*/
insert into scott.result(bh,xm,lb,zhengzhi,yingyu,zhuanye1,zhuanye2,zhuanye3,totalscore,flag) values(graduaterecord.bh,graduaterecord.xm,graduaterecord.lb,graduaterecord.zhengzhi,graduaterecord.yingyu,graduaterecord.zhuanye1,graduaterecord.zhuanye2,graduaterecord.zhuanye3,graduatetotalscore,graduateflag);
end loop;
/*关闭游标*/
close graduatecursor;
/*提交结果*/
commit;
/*异常处理,提示错误信息*/
exception
when errormessage then
dbms_output.put_line('无法打开数据表');
/*程序执行结束”*/
end;
怎么就提示:警告: 创建的过程带有编译错误。有高手知道的话,帮忙看看,解决一下,谢谢了啊!!!!