Solved

Execute immediate will auto commit sql statement before

Posted on 2007-11-25
1
11,651 Views
Last Modified: 2013-12-07
Is Execute immediate will commit the update statement execute before?
In the example below when error happen when execute procedure Proc_1 at update table2, i notice that the update statement for table1 has been committed. If i uncomment the execute immediate statement, update table1 will not commit, anyone knows why this happen?

CREATE OR REPLACE Procedure Proc_1 As
 Begin
        -- UPDATE Table  1      
        Update table1 Set col1 = 'Col1';
       
      -- Execute immediate
       execute immediate ('Alter trigger trigger1 disable');
       
        -- Update Table 2      
        Update Table2 Set col2 = 'Col2';
        Commit;
     End If;
  Exception
     When others Then
      Rollback;
       Raise_application_error(-20747, Sqlcode || ' ' || Sqlerrm);
End;
0
Comment
Question by:yuching
1 Comment
 
LVL 13

Accepted Solution

by:
sonicefu earned 125 total points
ID: 20348524
No, execute immediate does not commit automatically. In your example update in table1 was commited due to DDL statement (Alter trigger trigger1 disable). DDL statements commit previously executed DML statements whether DDL statement successfully executed or not.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
exp/imp 25 84
PL/SQL More than one element associated with another element 7 44
Oracle function to insert records? 15 47
Procedure syntax 5 38
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to recover a database from a user managed backup

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question