Wednesday, April 10, 2013

DML operations with Evaluate


DML operations with Evaluate

Is it possible to do a DML operations, Insert/Update/Delete with Evaluate function?

Yes, We can do it. 


If we issue an Evaluate function in the report, the BI query will be something like :

 Select Evaluate('f1(%1)',Table_Name.Column_Name ) from "Subject Area" 

In Oracle, its not possible to do an Insert/Update/Delete from a select clause.

So in order to achieve this We need to have a Clause 'Pragma Autonomous_transaction;' in the underlying function called in the Evaluate.

Pragma Autonomous Transaction: 

Definition : 

An autonomous transaction is an independent transaction that is initiated by another transaction, and
executes without interfering with the parent transaction. When an autonomous transaction is called, the
originating transaction gets suspended. Control is returned when the autonomous
transaction does a COMMIT or ROLLBACK.

Example: 

Create or replace function test_proc( param IN VARCHAR2 )
return INTEGER as
PRAGMA AUTONOMOUS_TRANSACTION;
Begin
  update <table> set <column1> = param ;
    commit;
 end test_Proc;
-------------------------------------

As per the definition, we can make this Insert/Update/Delete as an independent transaction from the main report and can perform DML operation.

2 comments:

  1. Exact2pass.com provides authentic IT Certification exams preparation material guaranteed to make you pass in the first attempt. Download instant free demo & begin preparation. VMware 3V0-624 dumps

    ReplyDelete
  2. Nobody wants to fail at achieving their dreams and if you are troubled by VMware and are looking for solutions! I would be more than happy to share my secret. I passed the test in just one attempt using 3V0-624 Practice Test Questions Answers I found at reasonable cost at Grades4sure. I am sure using these 3V0-624 Question Answers Dumps you can accomplish your goals too. What’s better is these free 3V0-624 Question Answers follow the same pattern as in exam.

    ReplyDelete