Search code examples
oracle-databaseplsqlprocedure

What's wrong with this simple block? PL SQL


i'm trying to run this simple anonymous block on TOAD but i get the following error. Can someone help me?

That's the code:

BEGIN
FOR REC_CONF IN
(       
    SELECT DISTINCT CONF.SCHEMA, CONF.TABELLA, CONF.CAMPO, CONF.TIPO_CAMPO, CONF.LUNG_CAMPO, 
CONF.CAMPO_ACCESSO
    FROM EDWH.EDWH_GDPR_CONFIG CONF
    WHERE UPPER(FLAG_CANC) = 'Y'
    AND UPPER(SCHEMA) = UPPER('EDWH')
    ORDER BY CONF.TABELLA, CONF.CAMPO ASC
)
LOOP

    DBMS_OUTPUT.PUT_LINE (REC_CONF.TABELLA);
END LOOP;
END;

This should loop into the EDWH.EDWH_GDPR_CONFIG and print out the attribute into the dbms_output.put_line.

This is the error i get:

[Error] Execution (10: 8): ORA-06550: row 10, column 8:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

   ( begin case declare exit for goto if loop mod null pragma
   raise return select update while with <an identifier>
   <identifier between quotes>
   <a bind variable> << continue close current delete fetch
   lock insert open rollback savepoint set sql execute commit
   forall merge pipe purge)

Solution

  • I believe that you ran the script in a wrong manner. It is a PL/SQL script, so run it either by pressing the F9 key, or pushing the "Execute as script" button in TOAD's toolbar.

    If cursor was placed somewhere in this code (e.g. on the BEGIN) and you pressed <Ctrl + Enter>, then you'll get

    ORA-06550: line 12, column 4: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge

    So - run it as script.