1

Topic: Call of a part of a script from the main script.

Let's assume that there are 2 scripts: 1.sql and 2.sql .
The Source code 1.sql:

with t1 as (select 1 a from dual)
@2.sql
/

The Source code 2.sql:

select * from t1

As we see, 2.sql it is caused from 1.sql .
At start 1.sql - we receive an error

"00928. 00000 -" missing SELECT keyword"

Actually a question: how to implement script sharing, in a case when is with, and further, in other script, already is select?
Tried to launch in SQL Developer and SQL*PLUS - result identical. The script 2.sql is visible (at least if it to cause separately the code is executed).

2

Re: Call of a part of a script from the main script.

C: \_ work> type 1.sql
select banner from v$version where rownum = 1;
with t1 as (select 1 a from dual)
@2.sql
exit;
/
C: \_ work> type 2.sql
select * from t1;
C: \_ work> sqlplus-s system/qqq@DMASLOV @1.sql
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
A
----------
1
C: \_ work>

3

Re: Call of a part of a script from the main script.

tFNiYaFF;
Include "echo on" and you will see, what exactly is caused

4

Re: Call of a part of a script from the main script.

Single and double @@ in SQLPLUS wrote:

A single symbol runs a script in the current directory ( or one specified with a full or relative path, or one that is found in your SQLPATH or ORACLE_PATH).
@@ will start a sqlplus script that is in the same directory as the script that called it (relative to the directory of the current script). This is normally used for nested command files .

5

Re: Call of a part of a script from the main script.

Viewer, you, as if, not in course, what so it is possible to substitute contents of other file in the current buffer?

6

Re: Call of a part of a script from the main script.

W: \> sqlplus/nolog
SQL*Plus: Release 11.2.0.4.0 Production on Mon Mar 12 11:14:47 AM 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL> conn system/xxxx@yyyy
Connected.
SQL> @1.sql;
SP2-0310: unable to open file "1.sql"
SQL> - single in @1.sql
SQL> @p:\1.sql;
SP2-0310: unable to open file "2.sql"
with t1 as (select 1 a from dual)
*
ERROR at line 1:
ORA-00928: missing SELECT keyword
SQL> - double in 11.sql
SQL> @p:\11.sql;
A
----------
1
SQL>

7

Re: Call of a part of a script from the main script.

Elic wrote:

Viewer, you, as if, not in course, what so it is possible to substitute contents of other file in the current buffer ?

Did not reflect... Simply used.