Register Login

Can We Use DML Operations in Functions?

Updated May 18, 2018

Hello Experts,

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

Kindly share your valuable views here.

Thanks in advance.


Comments

  • 08 Oct 2015 6:29 pm Abhijeet Mudgal 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 Chandan Singh Parihar 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


×