Search code examples
sqloracle-sqldeveloperoracle12c

SQL Developer multiple CREATE TYPE statements in one file


I would like to run a script in SQL Developer (for Oracle 12c) which creates 2 types and a stored procedure from a single SQL file. Something like:

CREATE OR REPLACE TYPE t_arr_five IS VARRAY(5) OF INTEGER;

CREATE OR REPLACE TYPE t_arr_ten IS VARRAY(10) OF INTEGER;

CREATE OR REPLACE PROCEDURE my_proc(
  p_a IN t_arr_five,
  p_b IN t_arr_ten
) AS
BEGIN
  -- ...
END;

When I run this script, I get the error: Error(3,1): PLS-00103: Encountered the symbol "CREATE"

Due to submission requirements, I must submit a single, runnable script (.SQL file), so I cannot execute one statement at a time.

What is the correct syntax to achieve this?


Solution

  • Turns out the solution is quite simple. All that's needed is to add a / after each CREATE statement on its own line:

    CREATE OR REPLACE TYPE t_arr_five IS VARRAY(5) OF INTEGER;
    /
    CREATE OR REPLACE TYPE t_arr_ten IS VARRAY(10) OF INTEGER;
    /
    CREATE OR REPLACE PROCEDURE my_proc(
      p_a IN t_arr_five,
      p_b IN t_arr_ten
    ) AS
    BEGIN
      -- ...
    END;