Re: SqlPlus Question

From: Jensen Langford - Sun UK - Contractor <jensen.langford_at_uk.sun.com>
Date: 1997/03/27
Message-ID: <333A596F.7226_at_uk.sun.com>#1/1


Bob Malos wrote:
>
> We have an ad-hoc query tool for the Web that was built to work with SYBASE
> databases. The CGI scripts just build some SQL and then run it in a 'batch'
> mode via SYBASE's ISQL utility.
>
> I'm wondering whether we can do the same thing with SqlPlus. With ISQL you can
> actually invoke it from a command line like this:
> ISQL -SSYBASE -Uxxxx -Pxxxx -i input.txt -o output.txt
> This takes the SQL that's in 'input.txt' and runs it, putting the output in
> 'output.txt'. (then the CGI script just reads the output file)
>
> Also - we often have several of these ISQL sessions running concurrently
> (using different UserIDs). Our platform is OS/2 and I know that SQL*Plus is
> available for OS/2.
>
> Bob Malos - Univ of Minnesota - malos001_at_tc.umn.edu

Hi Bob

You certainly can do this in sqlplus;

Usage: SQLPLUS [<option>] [<user>[/<password>] [_at_<host>]]

               [_at_<startfile> [<parm1>] [<parm2>] ...] where <option> ::= { -s | -? }
-s for silent mode and -? to obtain version number

sqlplus -s username/passwd _at_script

-s: supressess garbage about version numbers etc. _at_script: any file ending .sql

with regard to report output either you can use some type of o/s redirection ie > unix or within the sqlplus script you can use one of the many sqlplus commands to redirect to a file

Example.

script.sql



select * from my_table

spool report.txt
/
spool off



/ actually causes the sql command to run.

Hope this helps.

-- 
                           _____
                          /~   ~\
                         |_ AGV  |
                         |/     __-__
                          \   /~     ~~-_
                           ~~ -~~\   J   ~\
                            /     |   E    \
               ,           /     /     N    \
             //   _ _---~~~    //-_     S    \
           /  (/~~ )    _____/-__  ~-_       _-\             _________
         /  _-~\\0) ~~~~         ~~-_ \__--~~   `\  ___---~~~        /'
        /_-~          G            _-/'          )~/               /'
        (___________/   S        _-~/'         _-~~/             _-~
     _ ----- _~-_\\\\     X   _-~ /'      __--~   (_ ______---~~~--_
  _-~         ~-_~\\\\      R(   (     -_~          ~-_  |          ~-_
 /~~~~\          \ \~~       ~-_ ~-_    ~\            ~~--__-----_    \
;    / \ ______-----\           ~-__~-~~~~~~--_             ~~--_ \    .
|   | \((*)~~~~~~~~~~|      __--~~             ~-_               ) |   |
|    \  |~|~-----
 
Received on Thu Mar 27 1997 - 00:00:00 CET

Original text of this message