Re: How to query Oracle from UNIX (AIX)?

From: Scott Daniels <scottdan_at_connix.com>
Date: 1997/01/23
Message-ID: <32E835A6.B41_at_connix.com>#1/1


Per Gunnare wrote:
>
> I want to extract data from Oracle Server 7 into textfiles from
> a UNIX (AIX) machine. What do I need to be able to do this?
>
> I prefer not to spend a lot of money so I would like to have
> somthing that let me submit an SQL query and get back the
> result which could be redirected to a text file.

Try tbe following at your shell prompt:
This command outputs the fields listing for a given table: $ echo "describe my_table;" | sqlplus \/

This command gets all records that meet your criteria: $ echo "select * from my_table where age >30;" | sqlplus \/

Notes:
1) you must escape the '/' after sqlplus 2) the command (in quotes) must end in a ';', just as if you

   had entered it from within sqlplus
3) if it is very long, or you wish to be able to execute the

   command from time to time, you can put the command in a text    file; then do:
    $ cat foo.sql | sqlplus \/

I use this quite frequently with Oracle server 7 under HP-UX. The output is a bit messy (column headings repeat), but you can redirect the output to a file and then edit it.

Hope this helps.
Scott Received on Thu Jan 23 1997 - 00:00:00 CET

Original text of this message