Online Tutorials & Training Materials |
Register Login

Can We Use DML Operations in Functions?

|| || 2

Can We Use DML Operations in Functions?

Hello Experts,

I have this query that can we use DML operations in Functions?

Kindly share your valuable views here.

Thanks in advance.


  • 08 Oct 2015 6:29 pm Helpful Answer

    You can use DML inside a PL/SQL function.However, the function can only be called from PL/SQL, not from SQL.

  • 08 Oct 2015 6:30 pm Helpful Answer

    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