我試圖運行在Oracle這個SQL腳本,並得到一個錯誤ORA-00984:列這裏不允許使用動態SQL
ORA-00984:列在這裏不允許。
declare
tablename varchar2(200):='imagesroom';
temp varchar2(50):='room_id';
iid number:=1;
dir varchar2(200):='imgdirroom';
in_fname varchar2(100):='img1.jpg';
obj ORDIMAGE;
ctx RAW(64) := NULL;
begin
execute immediate 'INSERT INTO '||tablename||'('||temp||',extension,icon)
VALUES(iid,'''',ORDImage(''FILE'',upper(dir),in_fname))
RETURNING icon INTO obj';
end;
/
ERROR at line 1:
ORA-00984: column not allowed here
ORA-06512: at line 10
這一個偉大的工程
INSERT INTO imagesroom(room_id,extension,icon)
VALUES(iid,'',ORDImage('FILE',upper(dir),in_fname))
RETURNING icon INTO obj;
這有什麼錯呢?
如果我去做了這樣
execute immediate 'INSERT INTO :table(:type,extension,icon)
VALUES(:id,'''',ORDImage(''FILE'',upper(:dir),:fname)) RETURNING icon INTO obj'
using tablename,temp,iid,dir,in_fname;
然後
ERROR at line 1:
ORA-00903: invalid table name
ORA-06512: at line 10
出現...
相關:在動態SQL DDL/SCL語句爲什麼不能使用綁定變量?](HTTP://計算器.com/q/25489002/1461424) – Krumia