Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to invoke Windows SQL command from a batch file?
Comments embedded.
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';
> ------------------------------------------------
>
Looks like three lines to me.
> But when I run test.bat from the command line, it is not giving me
the
> output of the "select" command.
>
That is because the batch file executes the sqlplus command and transfers control to THAT interface. It won't get to the 'query' until you exit SQL*Plus. This is not like a UNIX/Linux shell where you can redirect input to another program or script using <<:
sqlplus user/pass_at_server <<EOF
select bytes/power(1024,3) from dba_segments where
segment_name='ATTACHMENTS_BLOB';
EOF
Windows batch files don't work in that manner.
> How can I get the command output from a batch file without logging
into
> the SQL shell?
>
Others have told you this, but I'll repeat it:
test.bat:
sqlplus srini/srini_at_srini @test
test.sql:
select bytes/power(1024,3) from dba_segments where
segment_name='ATTACHMENTS_BLOB';
exit
> Thanks in advance,
> Srini
Read the manual next time: tahiti.oracle.com.
David Fitzjarrell Received on Wed Apr 27 2005 - 23:16:53 CDT
![]() |
![]() |