views:

214

answers:

1

I have a file to execute in Ksh written by someone. It has a set of commands to execute in sqlplus.

It starts with,

sqlplus -s $UP <<- END

followed by a set of ddl commands such as create,drop,etc.,

When I execute the file in the shell, I get the error in the starting line quoted above. I understand "-s" starts the sqlplus in silent mode and $UP is the connection string with username/password. But I couldn't make heads or tails of "<<- END" part(Many sites from google says input redirection is "<<" not "<<-"). So I presumed the error must be in that part and removed it from the file. Now it reads,

sqlplus -s $UP 

But once I execute the file, It waits for input from the shell, instead of reading the rest of the lines from the file. How would I make sqlplus to execute the ddl commands in the rest of the file?. Thanks in advance.

+1  A: 

Here "END" is a block marker and "-" is not required.

For running sqls from a shell script , One simple example is given below.

sqlplus system/manager << ENDOFSQL 

       whenever sqlerror exit sql.sqlcode;
       select sysdate from dual;
       exit;
ENDOFSQL

Thanks,

Rinson KE DBA

RINSON KE