0

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)
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
Jackwiper
  • 3
  • 5
  • In addition to the answers below (please don't forget to mark the relevant answer as correct!) there may also be an option in the preferences to treat blank lines as terminators, which you could disable and then "execute" would run it as expected. (as per [this answer on the toadworld forum](https://forums.toadworld.com/t/ignore-blank-lines-within-the-sql-editor-for-sql/38103), although that's referring to 12.9; I'm pretty sure this option was available in earlier versions). Or you could just remove blank lines from your procedure. – Boneist Jan 09 '20 at 11:46
  • 1
    Which is also a good solution. I've just did it. To other Users: Disable “Treat blank line as statement terminator” in Toad Options on the Execute/Compile page. – Jackwiper Jan 09 '20 at 12:01

2 Answers2

1

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.

Littlefoot
  • 131,892
  • 15
  • 35
  • 57
0

Try to add '/' after last "END;"

END LOOP;
END;
/

and execute again

ekochergin
  • 4,109
  • 2
  • 12
  • 19