I'm trying to insert random generating data into table, here's code"
begin
FOR x in 1..300 LOOP
Execute immediate 'insert into emp values ('||prac_seq.nextval||','''||'name'||x||''','||trunc(dbms_random.value(1,300))||');';
end loop;
/
table emp
has 3 columns - id
,name
,idmgr
;
above query in execute immediate statement looks like:
insert into emp values (13,'name25',193);
This block did not run. When I tried to run single execute immediate statement (f.e.
begin
Execute immediate 'insert into emp values ('||prac_seq.nextval||','''||'name23'','||trunc(dbms_random.value(1,300))||');'
end;
/
ORA gives me an error:
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:
And why? Commas, quotes.. everything is checked and fine.
execute immediate
) in this case at all - use static SQL. – Nick Krasnov