我想随机生成数据插入到表中,这里的代码”甲骨文,执行直接插入
表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秒!所以是的 - 有需要。 –