Chibak
Chibak

Reputation: 233

How to execute .sql file using another .sql file in Oracle?

I try to start cr_tb.sql file using another start.sql file and get an error unknown command beginning pid number... The strange thing is that when I simply copy paste the cr_tb.sql content into the SQL*Plus, it executes perfectly.

What am I doing wrong? (I have posted the dropbox links)

Upvotes: 4

Views: 1129

Answers (1)

Nick Krasnov
Nick Krasnov

Reputation: 27251

The root of the problem lays in the create table frclubs statement. There are blank lines in

the table definition:

create table frclubs
(
    -- here they are

pid number(2) not null,
clubid number(2) not null,
constraint cPIDCLUBIDPK primary key(pid,clubid),
constraint fPIDFK foreign key(pid) references friends(pid),
constraint fCLUBIDFK foreign key(clubid) references clubs(clubid)
);

You have two choices:

  1. Remove blank lines in the create table frclubs DDL statement;

  2. Allow SQL*PLUS ignore blank lines in the script issuing SET SQLBLANKLINES ON command.

Upvotes: 4

Related Questions