使用显示游标,分别查询emp表的员工部门为20以及30的empno ename
展开全部
CREATE OR REPLACE PROCEDURE XXX
AS
cursor cur_emp is
select empno,ename from emp where empno=20 or empno=30
rEmp cur_emp%rowtype;
BEGIN
BEGIN
OPEN cur_emp;
LOOP
FETCH cur_emp INTO rEmp;
EXIT WHEN cur_emp%NOTFOUND;
END LOOP;
CLOSE cur_emp;
COMMIT WORK;
EXCEPTION
WHEN OTHERS THEN
CLOSE cur_emp;
ROLLBACK WORK;
DBMS_OUTPUT.PUT_LINE('stat failed,error code:'||SQLCODE||',error message:'||SUBSTR(SQLERRM,1,100));
END;
END;
AS
cursor cur_emp is
select empno,ename from emp where empno=20 or empno=30
rEmp cur_emp%rowtype;
BEGIN
BEGIN
OPEN cur_emp;
LOOP
FETCH cur_emp INTO rEmp;
EXIT WHEN cur_emp%NOTFOUND;
END LOOP;
CLOSE cur_emp;
COMMIT WORK;
EXCEPTION
WHEN OTHERS THEN
CLOSE cur_emp;
ROLLBACK WORK;
DBMS_OUTPUT.PUT_LINE('stat failed,error code:'||SQLCODE||',error message:'||SUBSTR(SQLERRM,1,100));
END;
END;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询