Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
here is my code:


SQL
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;
/
Posted
Updated 14-Oct-15 20:28pm
v2
Comments
Afzaal Ahmad Zeeshan 14-Oct-15 16:40pm    
Java, .NET and SQL are different in many aspects. What do you actually want to do? Stored procedures are used in SQL, but how do you want to trigger them?

1 solution

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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900