Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Create SQL Batch File

Re: Create SQL Batch File

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: Thu, 09 Jan 2003 14:38:57 +0200
Message-ID: <avjjfv$t57$1@ctb-nnrp2.saix.net>


Mohamed Badr wrote:

> Hello,
> I want to make a linux or dos batch file to run a SQL Command
> i.e. SQLPLUS.exe scott/tiger SQL_COMMAND
> so how can I write this batch file like that.

Something like this (for Linux):
-- sql.sh script --
#!/bin/sh

# usage : sql.sh "SQL STATEMENT"

sqlplus -s << EOF
scott/tiger

$1
/

exit;

EOF
-- sql.sh script --

This will work for both SQL statements and PL/SQL blocks

Usage and output looks like this (pasted from bash):

$ sql.sh "select sysdate from dual"

SYSDATE



09-JAN-03 $ sql.sh "begin commit; end;"

PL/SQL procedure successfully completed.

--
Billy
Received on Thu Jan 09 2003 - 06:38:57 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US