这个procedure 写的不知道有什么问题,请帮看下

[复制链接]
查看11 | 回复8 | 2008-1-21 16:50:24 | 显示全部楼层 |阅读模式
/*这是一个用于从多表中查询更新另一个表的Procedure,但是在编译的时候总是报错
Warning: Procedure created with compilation errors,实在是搞不懂了请各位高人给看看*/
create or replace procedure proc_update_wce
( v_adate8 nvarchar2 ) as
declare
c_adate8 attendance.adate8%TYPE;
cursor c is
select e.emp_id,a.card_num,a.adate8,a.atime4,a.door,m.in_out
from employee e,attendance a,atten_machine m
where e.card_number = a.card_num
and a.door = m.ma_id
and a.adate8 = c_adate8
order by e.emp_id,adate8,atime4;
v c%ROWTYPE;
begin
open c(v_adate8);
loop
fetch c into v;
exit when c%notfound;
update work_calen_emp w
set in_time = v.atime4,
door_in = v.door
where w.emp_id = v.emp_id
and w.bmouth || w.bday = v_adate8
and v.in_ouit = 1;

update work_calen_emp w
set out_time = v.atime4,
door_out = v.door
where w.emp_id = v.emp_id
and w.bmouth || w.bday = v_adate8
and v.in_ouit = 2;
end loop;
close c;
end;
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
出错后,使用
show error
打印出错误信息,贴上来看看
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
declare不用写了吧,定义cursor时也没写参数
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
我是在pl/sql developer中编译的,谢谢楼上错误如下:
LINE/COL ERROR
-------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3/1PLS-00103: 出现符号 "DECLARE"在需要下列之一时: begin function package pragma procedure subtype type use form current cursor external language符号 "begin" 被替换为 "DECLARE" 后继续。
36/0 PLS-00103: 出现符号 "end-of-file"在需要下列之一时: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with
pipe
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
declare 不要写吗?
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
去掉declare 后的错误如下:
SQL> show error
Errors for PROCEDURE EPROJ.PROC_UPDATE_WCE:
LINE/COL ERROR
-------- ----------------------------------------------
14/11PLS-00306: 调用 'C' 时参数个数或类型错误
14/6 PL/SQL: SQL Statement ignored
23/16PLS-00302: 必须说明 'IN_OUIT' 组件
23/14PL/SQL: ORA-00904: "V"."IN_OUIT": 无效的标识符
18/10PL/SQL: SQL Statement ignored
30/16PLS-00302: 必须说明 'IN_OUIT' 组件
30/14PL/SQL: ORA-00904: "V"."IN_OUIT": 无效的标识符
25/10PL/SQL: SQL Statement ignored
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
OK 这个问题解决了,是我写错了
v.in_out 而不是v.in_ouit
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
这是完整的正确代码
create or replace procedure proc_update_wce
( v_adate8 nvarchar2 ) as
cursor c(c_adate8 attendance.adate8%type) is
select e.emp_id,a.card_num,a.adate8,a.atime4,a.door,m.in_out
from employee e,attendance a,atten_machine m
where e.card_number = a.card_num
and a.door = m.ma_id
and a.adate8 = c_adate8
order by e.emp_id,adate8,atime4;
v c%ROWTYPE;
begin
open c(v_adate8);
loop
fetch c into v;
exit when c%notfound;
update work_calen_emp w
set in_time = v.atime4,
door_in = v.door
where w.emp_id = v.emp_id
and w.bmouth || w.bday = v_adate8
and v.in_out = 1;

update work_calen_emp w
set out_time = v.atime4,
door_out = v.door
where w.emp_id = v.emp_id
and w.bmouth || w.bday = v_adate8
and v.in_out = 2;
end loop;
close c;
end;
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
呵呵
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行