编写一个存储过程完成学生转学的功能
请编写一个存储过程完成学生转学的功能。要求存储过程的入参为学生的学号和out类型的出参。out类型的出参为400表示转学成功,为500表示存储过程执行有异常,如果为300表示给定学号的学生不存在。
createor replace procedure changeschool(id in number ,rs out number) is cursor sc is select * from s where s.s_id=id;
srecord s%rowtype; begin open sc; fetch sc into srecord; if (sc%found) then insert into ss(s_id,s_name,entrance_time,department) values(srecord.s_id,srecord.s_name,srecord.entrance_time,srecord.department); delete from s where s.s_id=id; close sc; commit; rs:=400; else rs:=300; end if; exception when others then rollback; rs:=500; end changeschool;
|