我想在动态sql中更新表。
declare
x varchar2(10) := 'table_n';
begin
execute immediate 'update :1 set column_n = 12345' using x;
end;
我得到ORA-00903:表名无效
但是
declare
x varchar2(10) := 'table_n';
begin
execute immediate 'update ' || x || ' set column_n = 12345';
end;
作品。
第一个解决方案有什么问题?
答案 0 :(得分:1)
你不能在pl / sql
中对表名使用绑定变量答案 1 :(得分:0)
动态sql:
1.It generally uses the SQL statements at run time. (for the time which we don't have data at the compilation time).
2. The bind variable , in your query, `x`, uses it on runtime and execute the dynamic on run time.
3. the bind variable refered by colon is used after USING clause.
点击此处获取更多信息:http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/dynamic.htm
答案 2 :(得分:0)
“....您不能使用绑定参数将模式对象的名称传递给动态SQL语句....”