execute immediate v_sql的例子:
begin
v_sql := 'select channel_id from imp_sh_cms_channel where wg_code =' ||
in_wg_id;
execute immediate v_sql
into v_contentid;
exception
when no_data_found then
out_result := 1; -- can't find data in imp_sh_cms_channel
rollback;
return;
end;
直接使用sql的例子:
begin
select channel_id into v_contentid from imp_sh_cms_channel where wg_code=in_wg_id;
exception
when no_data_found then
out_result := 1; -- can't find data in imp_sh_cms_channel
rollback;
return;
end;
begin
v_sql := 'select channel_id from imp_sh_cms_channel where wg_code =' ||
in_wg_id;
execute immediate v_sql
into v_contentid;
exception
when no_data_found then
out_result := 1; -- can't find data in imp_sh_cms_channel
rollback;
return;
end;
直接使用sql的例子:
begin
select channel_id into v_contentid from imp_sh_cms_channel where wg_code=in_wg_id;
exception
when no_data_found then
out_result := 1; -- can't find data in imp_sh_cms_channel
rollback;
return;
end;
解决方案 »
- oracle创建存储过程 报错:pls-00103 : 出现符号 "create"
- 大家帮我存储过程怎么错了!!!!在线等!!!!!!!!
- 求oracle数据库的所有用户的统计上传的记录数的通用存储过程?
- 关于“'”的问题,请大家指教
- 很急~~~~~~~!
- orcale 9i 什么查看 top sql 进行优化???急
- 不管是用pl/sql developer链接还是在cmd下链接Oracle数据库,提示的错误基本上都是一样的。
- 求助:oracle数据的转存
- 紧急求助,建立快照问题
- 初级问题,在sql plus中写的sql语句按菜单运行时怎么只是回车,没有结果?
- oracle exp/imp 无法解析指定的连接标识符
- 求一sql或者过程
两者返回的结果是一样的,想你这样情况就没有必要用动态SQL
动态SQL是指SQL文不确定时,不同条件下,拼接出不同SQL文。
另外用动态SQL的另一种情况就是在programme中执行DDL语句
select channel_id from imp_sh_cms_channel where wg_code = '123';
select channel_id from imp_sh_cms_channel where wg_code = '456';--这是使用绑定变量
select channel_id from imp_sh_cms_channel where wg_code = :code;google一下:绑定变量http://www.google.com.hk/search?hl=zh-CN&source=hp&q=%E7%BB%91%E5%AE%9A%E5%8F%98%E9%87%8F&meta=&aq=f&aqi=&aql=&oq=&gs_rfai=
悲哀啊