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 10g 手动exp手动导出出错?
- plsql 与sqlplus查询出结果不同
- Oracle存储过程读取all_trigger_cols的怪异问题
- JDBC insert 返回ID 遇到的问题
- 请教!!!!!!!!!!!
- oracle 如何查看已经创建好的触发器语句
- 在select中,字段名是关键字 该如何处理
- 请问 Oracle9i JDeveloper 是什么东东,干什么用的?
- [求救] VisualStudio.net2002+Oracle9i开发中OraOLEDB.Oracle.1的问题,高手帮忙!
- oracle的表空间怎样设置?是对每一个表分别进行设置,还是对所有表同时进行设置,谢谢
- 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;