我想隨機生成數據插入到表中,這裏的代碼」甲骨文,執行直接插入
表emp
有3列 - id
,name
,idmgr
;
上面的查詢在執行立即聲明看起來像:
insert into emp values (13,'name25',193);
該塊沒有運行當我試圖運行單個執行immediat e聲明(f.e.
begin
Execute immediate 'insert into emp values ('||prac_seq.nextval||','''||'name23'','||trunc(dbms_random.value(1,300))||');'
end;
/
ORA給我一個錯誤:
Execute immediate 'insert into emp values ('||prac_seq.nextval||','''||'name23'','||trunc(dbms_random.value(1,300))||');'; end; Error report: ORA-00911: invalid character ORA-06512: at line 3 00911. 00000 - "invalid character" *Cause: identifiers may not start with any ASCII character other than letters and numbers. $#_ are also allowed after the first character. Identifiers enclosed by doublequotes may contain any character other than a doublequote. Alternative quotes (q'#...#') cannot use spaces, tabs, or carriage returns as delimiters. For all other contexts, consult the SQL Language Reference Manual. *Action:
爲什麼呢?逗號,引號..一切都檢查和罰款。
在這種情況下,不需要使用本地動態SQL('立即執行') - 使用靜態SQL。 –
在立即使用JUSt 2000插入語句之前。這需要很多時間。動態SQL - 7.54秒!所以是的 - 有需要。 –