CREATE OR REPLACE PROCEDURE stu_proc(v_name IN VARCHAR2 DEFAULT '张三', v_id OUT NUMBER) AS
--声明语句段
BEGIN
--执行语句段
SELECT id INTO v_id FROM student where sname=v_name;
EXCEPTION
--异常处理语句段
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('NO_DATA_FOUND');
END;
调用:
DECLARE
i NUMBER ;
BEGIN
stu_proc('张三',i);
dbms_output.put_line('查询到的ID为: '||i);
END;
结果:
网友评论