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:RE: How to run sql*plus and its command in Windows as b

Re:RE: How to run sql*plus and its command in Windows as b

From: <dgoulet_at_vicr.com>
Date: Thu, 20 Mar 2003 10:04:38 -0500
Message-Id: <24726.322545@fatcity.com>


Thom,

    If your going to go to all that trouble, why not simply create a .sql file & call it on the command line.

Dick Goulet

____________________Reply Separator____________________
Subject: RE: How to run sql*plus and its command in Windows as batc Author: "Mercadante; Thomas F" <NDATFM_at_labor.state.ny.us> Date: 3/20/2003 4:53 AM

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-----
Sent: Wednesday, March 19, 2003 10:19 PM To: Multiple recipients of list ORACLE-L

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 also send the HELP command for other information (like subscribing).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Mercadante, Thomas F
  INET: NDATFM_at_labor.state.ny.us
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 - 09:04:38 CST

Original text of this message

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