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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to invoke Windows SQL command from a batch file?

Re: How to invoke Windows SQL command from a batch file?

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 28 Apr 2005 06:19:25 -0700
Message-ID: <1114694365.019255.40610@f14g2000cwb.googlegroups.com>

srini wrote:
> Hi all,
>
> I have the following question:
>
> I have SQLPlus on my Windows 2000 box:
> -----------------------------------------------
> D:\upgrades\new\CC>sqlplus srini/srini_at_srini
> SQL*Plus: Release 8.1.7.0.0 - Production on Wed Apr 27 20:34:15 2005
> (c) Copyright 2000 Oracle Corporation. All rights reserved.
> Connected to:
> Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
> With the Partitioning option
> JServer Release 8.1.7.4.0 - Production
> SQL>
> ----------------------------------------------
>
> Now I want to have a batch file, test.bat with the following two
lines:
> --------------------------------------------------
> sqlplus srini/srini_at_srini
> select bytes/power(1024,3) from dba_segments where
> segment_name='ATTACHMENTS_BLOB';
> ------------------------------------------------
>
> But when I run test.bat from the command line, it is not giving me
the
> output of the "select" command.
>
> How can I get the command output from a batch file without logging
into
> the SQL shell?
>
> Thanks in advance,
> Srini

Others have suggested using a sql script... which is a standard approach on Windows and should be used.

However... If you have a single sql statement you can bypass a script and just do,
c:\> echo select sysdate from dual;|sqlplus user/pwd

This may not be very usefull since it prints all the garbage before and after the actual resultset... like heading, echo etc. It can be however usefull if e.g. you want to hide the password to sqlplus,

C:\> echo password|sqlplus user_at_database @somescript.sql

Regards
/Rauf Received on Thu Apr 28 2005 - 08:19:25 CDT

Original text of this message

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