How to create a UNIX script to login to SQLPLUS and run SELECT from SQLPLUS?
I have SQLPLUS script (in the myscript.sql file,for example) that runs a SELECT query and places an output into a flat file using SPOOL.
To run the script I need to login to SQLPLUS from my UNIX ksh prompt and then execute that script as @myscript.sql
I need to create a shell script file that would login to SQLPLUS and run the SQLPLUS script from there.
I tried to use this code below where everything starting from the line 3 is from the tested myscript.sql script. (The script itself is simplified here as much as possible).
But after I execute the shell script it just logins into SQLPLUS, displays the SQL prompt and does not do anything else.
What am I missing?
Thanks a lot in advance!
set echo off
set feedback off
set linesize 166
set pagesize 0
set sqlprompt ''
set colsep ""
set term off
set verify off
set trimspool on
SELECT sysdate from dual;