Y
Y
Yaroslav Timchenko2021-04-07 12:03:45
Oracle
Yaroslav Timchenko, 2021-04-07 12:03:45

What is wrong with oracle procedure?

After procedure call I want to make insert. But the program gives an error PLS-00103 - "Insert symbol encountered"

create or replace procedure on_drop(table_name char(100))
    BEGIN
         EXECUTE IMMEDIATE 'DROP TABLE ' + table_name + ' CASCADE CONSTRAINT;';
         
         execute immediate 'create table address(
         address_id number(9) GENERATED ALWAYS AS IDENTITY,
         address_country char(200) NOT NULL,
         address_region char(100) NOT NULL,
         address_district char(100) NOT NULL,
         address_settlement_type char(50) NOT NULL,
         address_settlement_name char(100) NOT NULL,
         PRIMARY KEY(address_id)
  );';
    EXCEPTION
         WHEN OTHERS THEN
                IF SQLCODE != -942 THEN
                     RAISE;
                END IF;
    END;  
END on_drop;

Calling a procedure

begin
  on_drop('address');
end;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Raushka, 2021-06-02
@Raushka

Rather, instead of +, you need to use ||, and you also need to pay attention to the apostrophes ' ', mainly because of them this problem happens!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question