Re: SQL*PLus script for running external scripts

From: ddf <oratune_at_msn.com>
Date: Mon, 9 Feb 2009 07:58:16 -0800 (PST)
Message-ID: <88ba7b59-322a-4900-b239-5a40038f0ba0_at_q18g2000vbn.googlegroups.com>



On Feb 9, 9:34 am, "Álvaro G. Vicario"
<alvaro.NOSPAMTH..._at_demogracia.com> wrote:
> ddf escribió:
>
>
>
>
>
> > The _at_@ syntax says 'run this script from the same location as the
> > source script', so if you do, indeed, locate all of these in one
> > directory the _at_@ syntax will be what you need.  As an example:
>
> > The directory contents --
>
> > c:\sql\orcl\examples\tst>dir
> >  Volume in drive C has no label.
> >  Volume Serial Number is A08D-1EEA
>
> >  Directory of c:\sql\orcl\examples\tst
>
> > 02/09/2009  07:55 AM    <DIR>          .
> > 02/09/2009  07:55 AM    <DIR>          ..
> > 02/09/2009  07:55 AM                76 master.sql
> > 02/09/2009  07:51 AM               138 script01.sql
> > 02/09/2009  07:54 AM               239 script02.sql
> >                3 File(s)            453 bytes
> >                2 Dir(s)  21,441,359,872 bytes free
>
> > c:\sql\orcl\examples\tst>
>
> > The master.sql script --
>
> > set echo on
> > spool master.log
> > _at__at_script01.sql
> > _at__at_script02.sql
> > spool off
>
> > Executing master.sql --
>
> > SQL> _at__at_script01.sql
> > SQL> create table yakima(
> >   2          snerg   number,
> >   3          florpal varchar2(40)
> >   4  );
>
> > Table created.
>
> > SQL>
> > SQL>
> > SQL> alter table yakima
> >   2  add constraint yakima_pk
> >   3  primary key(snerg);
>
> > Table altered.
>
> > SQL>
> > SQL> _at__at_script02.sql
> > SQL> create table terpal(
> >   2          sming varchar2(80),
> >   3          yertz   number,
> >   4          oplama  number
> >   5  );
>
> > Table created.
>
> > SQL>
> > SQL> alter table terpal
> >   2  add constraint terpal_pk
> >   3  primary key(sming);
>
> > Table altered.
>
> > SQL>
> > SQL> alter table terpal
> >   2  add constraint terpal_fk
> >   3  foreign key(yertz)
> >   4  references yakima;
>
> > Table altered.
>
> > SQL>
>
> I've copied your example line by line (it works fine) and started
> modifying it. The issue happened to be blank lines. It's okay if I have:
>
> create table yakima(
>         snerg   number,
>         florpal varchar2(40)
> );
>
> But it won't work with:
>
> create table yakima(
>         snerg   number,
>
>         florpal varchar2(40)
> );
>
> SQL> create table yakima(
>    2          snerg   number,
>    3
> SQL>         florpal varchar2(40)
> SP2-0734: inicio "florpal va..." de comando desconocido - resto de la
> lÝnea ignorado.
> SQL> );
> SP2-0042: comando desconocido ")" - resto de la lÝnea ignorado.
>
> Can't you have blank lines in script files?
>
> --
> --http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
> -- Mi sitio sobre programación web:http://bits.demogracia.com
> -- Mi web de humor al baño María:http://www.demogracia.com
> --- Hide quoted text -
>
> - Show quoted text -

You can, provided you set sqlblanklines ON --

SQL> set echo on sqlblanklines on
SQL> spool master.log
SQL> _at__at_script01.sql
SQL> create table yakima(
  2          snerg   number,
  3
  4          florpal varchar2(40)

  5 );

Table created.

SQL>
SQL>
SQL> alter table yakima

  2 add constraint yakima_pk
  3 primary key(snerg);

Table altered.

SQL>
SQL> _at__at_script02.sql
SQL> create table terpal(
  2          sming varchar2(80),
  3          yertz   number,
  4          oplama  number

  5 );

Table created.

SQL>
SQL> alter table terpal
  2 add constraint terpal_pk
  3 primary key(sming);

Table altered.

SQL>
SQL> alter table terpal
  2 add constraint terpal_fk
  3 foreign key(yertz)
  4 references yakima;

Table altered.

SQL> David Fitzjarrell Received on Mon Feb 09 2009 - 09:58:16 CST

Original text of this message