Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Commit Inside a Block

technimdaxviiiSep 15 2022

Hi,
I'm new in pl/sql. When doing DML inside a block, do I need commit? What is the best practice?

HR@SNDBX11> create table t (
  2  a NUMBER(2,0),
  3  b VARCHAR2(10));


Table created.


HR@SNDBX11> select a from t;


no rows selected


HR@SNDBX11> insert into t (a) values (1);


1 row created.


HR@SNDBX11> commit;


Commit complete.


HR@SNDBX11> select a from t;


         A
----------
         1


HR@SNDBX11> begin
insert into t (a) values (2);
end;  2    3
  4  /


PL/SQL procedure successfully completed.


HR@SNDBX11> select a from t;


         A
----------
         1
         2

This post has been answered by Paulzip on Sep 15 2022
Jump to Answer
Comments
Post Details
Added on Sep 15 2022
4 comments
1,407 views