-1

I have a SQL script that I am running in a shell. The problem is I am unable to get rid of the SQL in the spool file.

SQL file :

set termout off
set echo off
set pagesize 0
set linesize 18
set heading off
set feedback off
set tab off
set space 0
set verify off
set timing off
spool abc.dat
select
RPAD(abc,10,' '),
 LPAD(ssss,4,'0'),
LPAD(xxx,4,'0')
from  whtevertable where rownum < 10;
spool off
exit
EOF

abc.ksh

#!/bin/ksh
sqlplus /
 @datafile.sql

Am I calling the SQL script correctly?

Karmic Coder
  • 17,569
  • 6
  • 32
  • 42
vivek ashodha
  • 117
  • 1
  • 2
  • 10

1 Answers1

0

By unable to get rid of the SQL in the spool file do you mean that you are not able to avoid the presence of unnecessary headers and sql query output in the spool file or your control cannot come out from the SQL script(add a / at the end of the sql script instead of EOF, without any space before it)? Can you please explain further.
Also in-order to run the sql script from shell, try doing it this way.

sqlplus "/ as sysdba" @datafile.sql
or
sqlplus username/password@SID @datafile.sql

In second option @SID is optional. The way that you are trying sqlplus / @datafile.sql will prompt you for username and password. Next time when you want to check if you are calling something right or not, just execute that in shell prompt.

Pradhyoth
  • 148
  • 1
  • 4