0

I'm running these commands in Oracle SQL Developer 20.4.0.379.

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE works_in';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN
            RAISE;
        END IF;
END;

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE depends';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN
            RAISE;
        END IF;
END;

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE wards';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN
            RAISE;
        END IF;
END;

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE doctors';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN
            RAISE;
        END IF;
END;

Then it returns an error:

Error report -
ORA-06550: line 10, column 1:
PLS-00103: Encountered the symbol "BEGIN" 
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

On the other hand, when I run each PL/SQL blocks one-by-one, there is no error. Could you please elaborate on this issue?

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
Akira
  • 2,594
  • 3
  • 20
  • 45
  • 1
    What happens if you enclose everything in one parent block like `BEGIN BEGIN ... END; ... BEGIN ... END; END;`? – sticky bit Feb 02 '21 at 23:16
  • @stickybit I'm new to SQL. Could you elaborate more? – Akira Feb 02 '21 at 23:20
  • 2
    PL/SQL blocks should be separated by forward slash (`/`) in SQL*Plus, and the same is in F5 mode of SQL Developer. For more explanation check [this thread on SO](https://stackoverflow.com/questions/1079949/when-do-i-need-to-use-a-semicolon-vs-a-slash-in-oracle-sql/10207695). – astentx Feb 02 '21 at 23:22
  • 1
    I'm afraid, no, I cannot. I already outlined what I mean. What don't you understand? – sticky bit Feb 02 '21 at 23:22
  • 1
    Thank you so much @astentx. Lacking `/` is the gist of my problem. I hope that you can write your comment as answer so that I can accept it. – Akira Feb 02 '21 at 23:26

0 Answers0