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!

Encountered the symbol "COMMIT" - Why is it so ?

LazarJun 25 2019 — edited Jul 19 2019

Hi All,

For the below code i'm not getting any error in SQL developer.

When executing the same SQL plus im facing below error. Why is it so ??

Below is not the actual code and it just a sample which is also throwing the COMMIT error. Please advise

SET DEFINE OFF;

SET SERVEROUTPUT ON;

SET TIMING ON

PROMPT #___________________________________________#

DECLARE

CURSOR C1 IS

select level from dual connect by level < =10;                                                               

                                               

BEGIN

FOR REC IN C1

LOOP

BEGIN

DBMS_OUTPUT.PUT_LINE(REC.LEVEL);

EXCEPTION

WHEN OTHERS THEN

DBMS_OUTPUT.PUT_LINE('Error: Others ');

END;

END LOOP;

COMMIT;

END;

COMMIT;

PROMPT #___________________________________________#

SET ESCAPE ON;

SET DEFINE ON;

SET SERVEROUTPUT OFF;

SET TIMING OFF;

Error Log:-

05:00:45|INFO> #___________________________________________#

05:00:45|INFO> COMMIT;

05:00:45|INFO> *

05:00:45|INFO> ERROR at line 27:

05:00:45|INFO> ORA-06550: line 27, column 1:

05:00:45|INFO> PLS-00103: Encountered the symbol "COMMIT"

05:00:45|INFO> Elapsed: 00:00:00.01

05:00:45|INFO> #___________________________________________#

This post has been answered by Solomon Yakobson on Jun 25 2019
Jump to Answer
Comments
Post Details
Added on Jun 25 2019
18 comments
3,827 views