ora-14552: cannot perform a ddl, commit or rollback inside a query or dml
cause: ddl operations like creation tables, views etc. and transaction control statements such as commit/rollback cannot be performed inside a query or a dml statement.
action: ensure that the offending operation is not performed or use autonomous transactions to perform the operation within the query/dml operation.
eg:
create or replace function osm_dml_3sp.osm_tab_funcfunc1(t in integer)
return integer is rt integer;
col0 osm_tab_func.col_0%type := 48;
begin
savepoint do_del;
delete from osm_dml_3sp.osm_tab_func where col_0 < col0 t;
if sql%found then
rollback to do_del;
insert into osm_dml_3sp.osm_tab_func select * from osm_dml_3sp.osm_tab_func;
commit comment 'insert data two times.';
end if;
select count(*) into rt from osm_dml_3sp.osm_tab_func;
return rt;
end;
-- this is the correct write
declare
cursor c1(tc varchar2) is select col_0 from osm_dml_3sp.osm_tab_func
where col_3 like '%'||tc||'%';
rfunt integer;
begin
for tc in c1('6') loop
rfunt := osm_dml_3sp.osm_tab_funcfunc1(52);
update osm_dml_3sp.osm_tab_func set col_0=rfunt where col_0=tc.col_0;
end loop;
end;
/
-- this is the error write
declare
cursor c1(tc varchar2) is select col_0 from osm_dml_3sp.osm_tab_func
where col_3 like '%'||tc||'%';
begin
for tc in c1('6') loop
update osm_dml_3sp.osm_tab_func set col_0=osm_dml_3sp.osm_tab_funcfunc1(52)
where col_0=tc.col_0;
end loop;
end;
/
ora-14552: cannot perform a ddl, commit or rollback inside a query or dml
ora-06512: at "osm_dml_3sp.osm_tab_funcfunc1", line 1
ora-06512: at line 1
阅读(3976) | 评论(0) | 转发(0) |