[英]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.