PL / SQL创建更新问题的程序(大学练习)
问题描述:
您好。
我需要创建一个存储过程,允许根据代码更改教师名称
。
此程序应在成功时返回值1,否则返回值0.
我这样做了:
创建或替换程序ChangeName(codeT in number,name in varchar2)
as
开始
更新老师设置的teachername =姓名,其中codeteacher = codeT;
end;
它工作正常..但我还需要:
Hello.
I need to create a stored procedure that allows to change the name of a teacher
based on their code.
This procedure should return a value of 1 on sucess and the value 0 otherwise.
I did this:
create or replace procedure ChangeName(codeT in number, name in varchar2)
as
begin
update teacher set teachername = name where codeteacher = codeT;
end;
And it works fine..but i need also to :"
return a value of 1 on sucess and the value 0 otherwise.
有人可以帮我做这个部分吗?
非常感谢您的关注!
"
Someone can help me to do this part?
Thank you very much for attention!
答
什么关于这个:
What about this:
create or replace procedure ChangeName
( codeT IN number
, name IN varchar2
, success OUT number
)
as
begin
update teacher set teachername = name where codeteacher = codeT;
if sql%rowcount = 1 then
success := 1;
else
success := 0;
end if;
end;