G
G
Gena2019-03-11 16:57:22
Oracle
Gena, 2019-03-11 16:57:22

How to call another script from one script?

Tell me how to call another script from one script.
Here is an example
- two scripts lie side by side. the first create.sql, the second test.sql
the first script checks for the presence of a table in the database and if it is missing, then it executes the second script to create it.

<i>create.sql</i>
declare
 table_exist number;
begin
  SELECT COUNT(1) INTO table_exist FROM   all_tables t WHERE  t.table_name = 'TEST';
  IF table_exist = 0 THEN
  execute immediate '@TEST';
  END IF;
end;
/
<i>test.sql</i>
create table TEST
(
  piu   VARCHAR2(500) not null,
  pou VARCHAR2(500)
);

alter table TEST
  add constraint PK_TEST primary key (piu)
  using index;

SQL> @!Create
declare
*
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 6

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xtender, 2019-03-11
@xtender

Like this: orasql.org/2013/04/17/sqlplus-tips-4-branching-exe...
In general, I have a miniseries of SQLPLus tips: orasql.org/category/oracle/sqlplus/sqlplus-tips

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question