在pl/sql developer中写一存储过程:
create or replace procedure add_table is
--变量赋值
g_jbf number;
g_jlf number;
g_zf number;
ceshi nvarchar2(50);
ceshi2 nvarchar2(20);--定义游标
cursor g_yb is
select --需要的字段
g_ceshi,
g_ceshi2
from --需要的表
table;begin
open g_yb;--打开游标
loop
fetch g_yb
into
ceshi,
ceshi2; g_jbf:=100; --基本分值初始化
g_jlf:=0; --奖励分值初始化
--奖励项目
if ceshi<>"" then g_jlf:=g_jlf+10;
--基本项目
if ceshi2="" then g_jbf:=g_jbf-20;
--总分
g_zf:=g_jbf+g_jlf;
--等级
if g_zf>=95 then g_dengji:='优秀';
if g_zf>=80 and g_zf<95 then g_dengji:='良好';
if g_zf>=70 and g_zf<80 then g_dengji:='合格';
if g_zf<70 then dengji:='不合格';
g_gradedate:=sysdate();
insert into table2(
jbf,
jlf,
zf,
dengji,
gradedate)
values (
g_jbf,
g_jlf,
g_zf,
g_dengji,
g_gradedate
);
exit when g_yb%notfound;
end loop;
close g_yb;
end add_table;
/
编译的时候,在"end loop" 上出现黄色光条,提示:
pls-00103:出现符号"loop" 在需要下列之一时:if
pls-00103:出现符号"end-of-file"在需要下列之一时:end
create or replace procedure add_table is
--变量赋值
g_jbf number;
g_jlf number;
g_zf number;
ceshi nvarchar2(50);
ceshi2 nvarchar2(20);--定义游标
cursor g_yb is
select --需要的字段
g_ceshi,
g_ceshi2
from --需要的表
table;begin
open g_yb;--打开游标
loop
fetch g_yb
into
ceshi,
ceshi2; g_jbf:=100; --基本分值初始化
g_jlf:=0; --奖励分值初始化
--奖励项目
if ceshi<>"" then g_jlf:=g_jlf+10;
--基本项目
if ceshi2="" then g_jbf:=g_jbf-20;
--总分
g_zf:=g_jbf+g_jlf;
--等级
if g_zf>=95 then g_dengji:='优秀';
if g_zf>=80 and g_zf<95 then g_dengji:='良好';
if g_zf>=70 and g_zf<80 then g_dengji:='合格';
if g_zf<70 then dengji:='不合格';
g_gradedate:=sysdate();
insert into table2(
jbf,
jlf,
zf,
dengji,
gradedate)
values (
g_jbf,
g_jlf,
g_zf,
g_dengji,
g_gradedate
);
exit when g_yb%notfound;
end loop;
close g_yb;
end add_table;
/
编译的时候,在"end loop" 上出现黄色光条,提示:
pls-00103:出现符号"loop" 在需要下列之一时:if
pls-00103:出现符号"end-of-file"在需要下列之一时:end
g_jlf:=g_jlf+10;
end if;//所有的都要加上
cursor g_yb is
select --需要的字段
g_ceshi,
g_ceshi2
from --需要的表
table;
你这个可以运行吗? table是关键字,应该是另一个表名吧!
很多if 都没有end if;
错误
ora-01400:无法将null插入("sys"."obj$"."name")小弟初学oracle,不太懂,请各位大哥帮忙指点一二!
...
end if;