errors ref: oracle 10.2 document
pls-00357: table,view or sequence reference 'string' not allowed in this context
cause: a reference to database table, view, or sequence was found in an inappropriate context. such references can appear only in sql statements or (excluding sequences) in %type and %rowtype declarations. some valid examples follow: select ename, emp.deptno, dname into my_ename, my_deptno, my_dept .from emp, dept where emp.deptno = dept.deptno; declare last_name emp.ename%type; dept_rec dept%rowtype;
action: remove or relocate the illegal reference.
begin
for i in 1 .. 984 loop
execute immediate 'insert into osm_dml_3sp.osm_tab_sequence(col_0) values(:1)'
using osm_dml_3sp.osm_tab_sequenceseq9.nextval;
end loop;
insert into osm_dml_3sp.osm_tab_sequence(col_0)
values(osm_dml_3sp.osm_tab_sequenceseq9.currval-45);
end;
/
sql> @/tmp/a
using osm_dml_3sp.osm_tab_sequenceseq9.nextval;
*
error at line 4:
ora-06550: line 4, column 47:
pls-00357: table,view or sequence reference
'osm_dml_3sp.osm_tab_sequenceseq9.nextval' not allowed in this context
ora-06550: line 3, column 5:
pl/sql: statement ignored
error use:
t := osm_dml_3sp.osm_tab_sequenceseq9.nextval;
correct use:
select osm_dml_3sp.osm_tab_sequenceseq9.nextval into t from dual;
>>>---
declare
t number;
begin
for i in 1 .. 984 loop
select osm_dml_3sp.osm_tab_sequenceseq9.nextval into t from dual;
execute immediate 'insert into osm_dml_3sp.osm_tab_sequence(col_0) values(:1)'
using t;
end loop;
insert into osm_dml_3sp.osm_tab_sequence(col_0)
values(osm_dml_3sp.osm_tab_sequenceseq9.currval-45);
end;
记得函数中有commit, rollback时也不可以直接用的, 真要好好注意, 感觉使用起来很怪!
function 中含有commit, rollback 出错的情况请看:
阅读(4004) | 评论(0) | 转发(0) |