CREATE OR REPLACE procedure modifyStuinfo
(
id in stuinfo.ID%type,
stuName in stuinfo.STUNAME%type,
password in stuinfo.PASSWORD%type,
stuClass in stuinfo.STUCLASS%type,
actor in stuinfo.ACTOR%type,
computer in stuinfo.COMPUTER%type,
message out varchar2
)
as
begin
execute immediate 'update stuinfo set stuName='||&stuName||',password='||&password||',stuClass='||&stuClass||',actor='||&actor||',computer='||&computer||' where id='||&id||';
commit;
message:='更新成功';
exception when others then
message:='更新失败;
rollback;
end;动态sql这一段有问题,不懂连接引号,字符型参数、整型参数的写法。参数id是整型,其他是字符。目前只作控制台输入和输出用。
解决方案 »
- Oracle RAC Install on Windows 2008
- 结合merge语句用于判断是执行INSERT还是UPDATE
- Oracle时间格式的奇怪问题.高手请进(实在没分了,请见谅)
- 查找完整性约束条件名的问题??
- 这样做可取吗?
- oracle 存储过程是用什么系统变量返回sql语句的执行结果的?
- 菜鸟求一SQL的查询语句急...........
- ORACAL 01033错误请高手帮忙。在线等……
- UTL_SMTP发送email指定authentication问题
- [求助]orcale创建触发器插入数据时进行判断修改后再插入的写法
- oracle集成管理问题
- 请问如何将Oracle的SQL脚本的执行结果存到一个文件里?
',password='||&password||',
最好改成',password='''||&password||''',这样比较保险,后面的一样
BEGIN
MESSAGE := '更新成功';
EXECUTE IMMEDIATE SQL_STMT
USING STUNAME, PASSWORD, STUCLASS, ACTOR, COMPUTER, ID;
EXCEPTION
WHEN OTHERS THEN
MESSAGE := '更新失败';
RETURN;
END;
execute immediate 'update stuinfo set stuName='''||stuName||''',password='''||password||''',stuClass='''||stuClass||''',actor='''||actor||''',computer='''||computer||''' where id='''||id||''';
CREATE OR REPLACE procedure modifyStuinfo
(
v_id in stuinfo.ID%type,
v_stuName in stuinfo.STUNAME%type,
v_password in stuinfo.PASSWORD%type,
v_stuClass in stuinfo.STUCLASS%type,
v_actor in stuinfo.ACTOR%type,
v_computer in stuinfo.COMPUTER%type,
message out varchar2
)
as
begin
MESSAGE := '更新成功';
update stuinfo
set stuName=v_stuName,
password=v_password,
stuClass=v_stuClass,
actor=v_actor,
computer=v_computer
where id=v_id;
commit;
EXCEPTION
WHEN OTHERS THEN
MESSAGE := '更新失败';
RETURN;
END;
(
id in stuinfo.ID%type,
stuName in stuinfo.STUNAME%type,
password in stuinfo.PASSWORD%type,
stuClass in stuinfo.STUCLASS%type,
actor in stuinfo.ACTOR%type,
computer in stuinfo.COMPUTER%type,
message out varchar2
)
as
begin
execute immediate 'update stuinfo set stuName='||stuName||',password='||password||',stuClass='||stuClass||',actor='||actor||',computer='||computer||' where id='||id||';
commit;
message:='更新成功';
exception when others then
message:='更新失败;
rollback;
end;