Oracle SQL Forum
I have this query that can we use DML operations in Functions?
Kindly share your valuable views here.
Thanks in advance.
You can use DML inside a PL/SQL function.However, the function can only be called from PL/SQL, not from SQL.
Generally you cannot do a dml in function and call the function in select.. The reason is "Select statement should not alter any data".. "SELECT" is not coming under DML.. but again by using Pragma Autonomous Transaction you can do.. The reason is when u use Pragma Autonomous Transaction, the DML Part will be executed in a Seperate Session (not from the Session where u issued select call).. but its never a god idea... Dont use DML in functions... Use Procedures
Sign up for STechies
Ask Question From Our Experts