存储过程编译出错,请大家帮忙看一下!

microchu 2003-06-23 02:42:53
Create OR REPLACE Package p_test
as
type NE_ID IS TABLE OF number(4) INDEX BY BINARY_INTEGER;
type DXC_NAME IS TABLE OF varchar(20) INDEX BY BINARY_INTEGER;
type Total_Port IS TABLE OF number(4) INDEX BY BINARY_INTEGER;
PROCEDURE pc_Stu(empID OUT NE_ID,empName OUT DXC_NAME,empTotalPort OUT
Total_Port);
END p_test;
/
CREATE OR REPLACE Package body p_test
as
PROCEDURE pc_Stu(empID OUT NE_ID,empName OUT DXC_NAME,empTotalPort OUT
Total_Port)
is
CURSOR c1 IS SELECT ID,NAME FROM NE_INFO WHERE Role =1 ORDER BY ID;
CURSOR c2 IS SELECT NE_INFO.ID,Count(NPC.NPC) AS cnum
From NE_INFO,NPC
Where NE_INFO.ID = NPC.NE_ID
GROUP BY NE_INFO.ID
ORDER BY NE_INFO.ID;
cnt NUMBER DEFAULT 1;
c c1%ROWTYPE;
cc1 c2%ROWTYPE;
Begin
OPEN c1;
LOOP
FETCH c1 INTO c;
empID(cnt) := c.ID;
empName(cnt) := c.NAME;
EXIT WHEN c1%NOTFOUND;
cnt := cnt + 1;
END LOOP;
CLOSE c1;
cnt := 1;
-----35行
OPEN c2;
LOOP
FETCH c2 INTO cc1;
IF cnt = cc1.ID + 1 then
empTotalPort(cnt) := cc1.cnum;
else
empTotalPort(cnt) := 0;
END IF
EXIT WHEN c2%NOTFOUND;
cnt := cnt + 1;
END LOOP;
CLOSE c2;
END pc_Stu;
END p_test;
/

错误提示:35/3 PLS-00103: 出现符号"EXIT"在需要下列之一时:
;
...全文
13 点赞 收藏 3
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
beckhambobo 2003-06-23
PROCEDURE pc_Stu(empID OUT NE_ID,empName OUT DXC_NAME,empTotalPort OUT
Total_Port)
is
CURSOR c1 IS SELECT ID,NAME FROM NE_INFO WHERE Role =1 ORDER BY ID;
CURSOR c2 IS SELECT NE_INFO.ID,Count(NPC.NPC) AS cnum
From NE_INFO,NPC
Where NE_INFO.ID = NPC.NE_ID
GROUP BY NE_INFO.ID
ORDER BY NE_INFO.ID;
cnt NUMBER DEFAULT 1;
--c c1%ROWTYPE;
--cc1 c2%ROWTYPE;
Begin
for v1 in c1 loop

empID(cnt) := v1.ID;
empName(cnt) := v1.NAME;

cnt := cnt + 1;
END LOOP;

cnt := 1;
-----35行
for v2 in c2 loop
--FETCH c2 INTO cc1;
IF cnt = v2.ID + 1 then
empTotalPort(cnt) := v2.cnum;
else
empTotalPort(cnt) := 0;
END IF
-- EXIT WHEN c2%NOTFOUND;
cnt := cnt + 1;
END LOOP;
--CLOSE c2;
END pc_Stu;
回复
Michaelyfj 2003-06-23
OPEN c1;
LOOP
FETCH c1 INTO c;
empID(cnt) := c.ID;
empName(cnt) := c.NAME;
EXIT WHEN c1%NOTFOUND;
cnt := cnt + 1;
END LOOP;
CLOSE c1;
cnt := 1;
-----35行
改为:

OPEN c1;
LOOP
FETCH c1 INTO c;
EXIT WHEN c1%NOTFOUND; --提前
empID(cnt) := c.ID;
empName(cnt) := c.NAME;
cnt := cnt + 1;
END LOOP;
CLOSE c1;
cnt := 1;
-----35行
回复
bobfang 2003-06-23
END IF后要加分号
回复
发动态
发帖子
基础和管理
创建于2007-09-28

1.7w+

社区成员

Oracle 基础和管理
申请成为版主
社区公告
暂无公告