oracle存储过程关于拼接update语句

create or replace procedure proc_updateuser(
usid in user_info.userid%type,
uname in user_info.username%type,
userpass in user_info.password%type,
effect_rows out smallint) as
basql varchar2(1000);
begin
update user_info set
username = uname,
password = userpass
where userid = usid;
--execute immediate basql;--执行动态sql
effect_rows :=1;
commit;
exception
when others then
effect_rows :=0;
rollback;
end proc_updateuser;
上面是我写的一个存储过程,功能是完成用户的信息修改。但是如果用户没有输入其中的一个参数的话,调用并执行过程后就会出现在修改的用户的某些列什么数据都没有了,因此我想在存储过程中判断并拼接sql,如果传了的参数才去修改,没有传的就不修改 。我用if语句进行拼接,但是都弄了一天,都有问题,如果遇到过类似问题的可以帮助一下啊,不胜感激呀。

你可能感兴趣的:(数据库)