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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to run sql*plus and its command in Windows as batch job

RE: How to run sql*plus and its command in Windows as batch job

From: Mercadante, Thomas F <NDATFM_at_labor.state.ny.us>
Date: Thu, 20 Mar 2003 07:52:32 -0500
Message-Id: <24726.322526@fatcity.com>


Chuan,

What I do is the following:

set DBA_TEMP=\sometempdirectory

echo connect test/test		> %DBA_TEMP%\run.sql
echo alter sesion set sql_trace=true	>>%DBA_TEMP%\run.sql
echo select count(*) from product_temp p, invoice_temp i	>>
%DBA_TEMP%\run.sql
echo where p.invpsid=i.invoiceid;	>>%DBA_TEMP%\run.sql
echo disconnect	>>%DBA_TEMP%\run.sql
echo exit		>>%DBA_TEMP%\run.sql

$ORACLE_HOME/bin/sqlplus /nolog @%DBA_TEMP%\run.sql

del %DBA_TEMP%\run.sql

just be aware of special characters that will not be echo'ed properly in NT scripting - thing like the | char will not work. You will need to "escape" these like this to get them to echo properly.

echo select col1^|^|col2 from sometable;

The advantage of this within NT bat files is that you can develop and use substitution characters inside the sql files. for example, if you wanted to spool a file where the name contains information from outside the Oracle session, you could do the following:

set ORACLE_SID=WTWD
echo spool %ORACLE_SID%_outfile.dat > run.sql

Hope this helps.

Tom Mercadante
Oracle Certified Professional

-----Original Message-----
From: Chuan Zhang [mailto:Chuan.Zhang_at_transact.com.au] Sent: Wednesday, March 19, 2003 10:19 PM To: Multiple recipients of list ORACLE-L Subject: How to run sql*plus and its command in Windows as batch job?

Hi, All,

  In unix, we can put following commands in a file and run that file. For example:

$ORACLE_HOME/bin/sqlplus /nolog << EOF

connect test/test
alter sesion set sql_trace=true
select count(*) from product_temp p, invoice_temp i where p.invpsid=i.invoiceid;
disconnect
exit
EOF What's the corresponding format on windows?

Your input is precious,

TIA Chuan

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Chuan Zhang
  INET: Chuan.Zhang_at_transact.com.au

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
Received on Thu Mar 20 2003 - 06:52:32 CST

Original text of this message

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