Rajeev
Rajeev

Reputation: 1371

sql script not showing output when run from UNIX CLI

following script is stored in file myscript

when i run it as oracle from UNIX CLI :

$./myscript 1234 2345

it does not show any output, but when i run the commands individually on the SQL prompt, they run fine and produce output.

can anyone help, why no output from UNIX CLI?

#!/bin/ksh
startDt=$1
endDt=$2
sqlplus mysqlroot/mysqlroot <<EOF >/dev/null
        SET TRIMOUT ON;
        SET FEEDBACK  OFF;
        SET PAGESIZE  0;
        SET VERIFY    OFF;
        set linesize 2300;
        set colsep |;
    select * from my_sales where saleTIME >= $startDt and saleTIME<= $endDt;
        exit;
EOF

Upvotes: 0

Views: 337

Answers (1)

paxdiablo
paxdiablo

Reputation: 881523

sqlplus mysqlroot/mysqlroot <<EOF >/dev/null
    blah blah blah
EOF

You're sending the standard output to the /dev/null device, the "bit bucket" where everything is thrown away.

This is best illustrated with the following transcript, where redirecting to /dev/null causes output to not appear:

pax> echo xyzzy >/dev/null
pax> echo xyzzy
xyzzy
pax> _

If you don't want it thrown away, just remove that output redirection:

sqlplus mysqlroot/mysqlroot <<EOF
    blah blah blah
EOF

Upvotes: 3

Related Questions