如何在单个函数中调用多个过程?请帮忙! [英] How to call multiple procedure within a single function ? Please help!

查看:62
本文介绍了如何在单个函数中调用多个过程?请帮忙!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:





here is my code:


create or replace function fn_dml_oprs
return number
as
procedure prc_insert
as
pragma autonomous_transaction;
begin
insert into t1 values(250) where A=20;
commit;
end;
procedure prc_update
as
pragma autonomous_transaction;
begin
update t1 set A=300 where A=10;
commit;
end;
procedure prc_delete
as
pragma autonomous_transaction;
begin
delete from t1 where A=30;
commit;
end;
begin
prc_insert;
prc_update;
prc_delete;
return 0;
end;
/

推荐答案

首先,你不能在函数中声明一个过程。这是因为您无法更改存储函数中的数据。这也意味着您无法从存储的函数调用存储过程。但是可以从存储过程中调用存储的函数。存储的功能必须是无副作用的。

另外,不要在这样的提交语句周围撒布,存储过程已经是事务性的。



祝你好运!
First of all, you can't declare a procedure in a function. This is because you cannot change data in a stored function. This also means you can't call a stored procedure from a stored function. But calling stored functions from stored procedures is possible. A stored function must be side effect free.
Also, DON'T sprinkle around commit statements like that, a stored procedure is already transactional.

Good luck!


这篇关于如何在单个函数中调用多个过程?请帮忙!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆