动态SQL 意思是字符串的内容的内容当做SQL来执行
语法: execute immediate '字符串内容'
execute 存储过程(参数)
|| 连接符 把左右两边的字符串的字符串连起来,合起来一个字符串 count +
遇到的情况和对策:
1 非查询,无参数
execute immediate '字符串';
execute immediate 'drop table Customer';
2 非查询,有参数
SQL中,用 :变量名 (代表一个参数,随便取名字)
execute immediate '动态SQL' using 实参列表
注意:
1,实参列表中,如果有多个参数,用逗号隔开
2,实参按照顺序依次替代SQL中的参数,不看参数名
3,实参的数据类型要符号SQL中参数的要求
-- Created on 2017/2/13 by ADMINISTRATOR
declare
-- Local variables here
i integer;
str varchar2(200);
begin
-- Test statements here
str :='select * fro
语法: execute immediate '字符串内容'
execute 存储过程(参数)
|| 连接符 把左右两边的字符串的字符串连起来,合起来一个字符串 count +
遇到的情况和对策:
1 非查询,无参数
execute immediate '字符串';
execute immediate 'drop table Customer';
2 非查询,有参数
SQL中,用 :变量名 (代表一个参数,随便取名字)
execute immediate '动态SQL' using 实参列表
注意:
1,实参列表中,如果有多个参数,用逗号隔开
2,实参按照顺序依次替代SQL中的参数,不看参数名
3,实参的数据类型要符号SQL中参数的要求
-- Created on 2017/2/13 by ADMINISTRATOR
declare
-- Local variables here
i integer;
str varchar2(200);
begin
-- Test statements here
str :='select * fro