[英]Dynamic sql - update table using table variable
我想更新动态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;
作品。
第一个解决方案出了什么问题?
您不能在pl / sql中为表名使用绑定变量
动态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
“ ....您不能使用绑定参数将架构对象的名称传递给动态SQL语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.