I have a question about EXECUTE IMMEDIATE. It does not need an explicit commit to commit DML statements. Is it...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
possible to force it not to commit until explicitly told to do so?
The EXECUTE IMMEDIATE command does not perform an implicit commit after every iteration. To verify this, I'll show a simple test case. First, I'll create a small table:
ORA9I SQL> create table test (id number); Table created.
ORA9I SQL> DECLARE 2 counter NUMBER; 3 BEGIN 4 FOR counter IN 1..5 LOOP 5 EXECUTE IMMEDIATE 'INSERT INTO test VALUES ('||counter||')'; 6 END LOOP; 7 ROLLBACK; 8 END; 9 / PL/SQL procedure successfully completed. ORA9I SQL> select * from test; no rows selected
ORA9I SQL> DECLARE 2 counter NUMBER; 3 BEGIN 4 FOR counter IN 1..5 LOOP 5 INSERT INTO test VALUES(counter); 6 END LOOP; 7 COMMIT; 8 END; 9 / PL/SQL procedure successfully completed. ORA9I SQL> select * from test; ID ---------- 1 2 3 4 5
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.