Unix Shell - Oracle Interaction From Shell

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > April 2005 > Oracle Interaction From Shell





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Oracle Interaction From Shell
Chris

2005-04-24, 5:48 pm

Does anyone know of a method, other than a sqlplus "here" document,
that can be used to interact with Oracle from a UNIX shell?

What I'd like to do is establish a connection and use it throughout the
execution of a shell script in order to query and update the database.

Using "here" documents to sqlplus can be quite expensive if the
functions are executed often.

I've considered using a co-process, but it seems that parsing the
results to find out whether the command succeeded or not would be quite
cumbersome.

I also know that I could use Pro*C, but a lot of what I am doing in the
shell script is somewhat of a PITA to incorporate within a C program.
Much easier/simpler to use shell.

Any thoughts from the group?

Thanks,
Chris

John L

2005-04-24, 5:48 pm


"Chris" <ctaliercio@yahoo.com> wrote in message news:1114198523.851244.294970@f14g2000cwb.googlegroups.com...
> Does anyone know of a method, other than a sqlplus "here" document,
> that can be used to interact with Oracle from a UNIX shell?
>
> What I'd like to do is establish a connection and use it throughout the
> execution of a shell script in order to query and update the database.
>
> Using "here" documents to sqlplus can be quite expensive if the
> functions are executed often.
>
> I've considered using a co-process, but it seems that parsing the
> results to find out whether the command succeeded or not would be quite
> cumbersome.
>
> I also know that I could use Pro*C, but a lot of what I am doing in the
> shell script is somewhat of a PITA to incorporate within a C program.
> Much easier/simpler to use shell.
>
> Any thoughts from the group?
>


It is not really clear what you are trying to do and
you might do better asking in an Oracle newsgroup but
having said all that, I suspect the answer may well
involve PERL and its DBI modules (so try PERL groups).

So far as the shell itself goes, you can echo commands
to sqlplus, check its exit value to see whether commands
succeeded or not (within sqlplus you can do something
like: on sqlerror exit 96, or whatever value you like)
and assign the output of sqlplus commands to shell variables
or (more likely) shell arrays.

--
John.


William Park

2005-04-24, 5:48 pm

Chris <ctaliercio@yahoo.com> wrote:
> Does anyone know of a method, other than a sqlplus "here" document,
> that can be used to interact with Oracle from a UNIX shell?
>
> What I'd like to do is establish a connection and use it throughout the
> execution of a shell script in order to query and update the database.
>
> Using "here" documents to sqlplus can be quite expensive if the
> functions are executed often.
>
> I've considered using a co-process, but it seems that parsing the
> results to find out whether the command succeeded or not would be quite
> cumbersome.
>
> I also know that I could use Pro*C, but a lot of what I am doing in the
> shell script is somewhat of a PITA to incorporate within a C program.
> Much easier/simpler to use shell.
>
> Any thoughts from the group?


I can't help you w.r.t. Oracle. But, you may be able to borrow few
things from
http://home.eol.ca/~parkw/index.html#sqlite
http://home.eol.ca/~parkw/index.html#postgresql
http://home.eol.ca/~parkw/index.html#mysql

Essentially, you build SQL strings, send it to database, and get the
results back (if any) in shell array variable. You can do the same
thing using client programs (ie. sqlite, mysql, psql), but you would
need to re-parse the result, which tends to be pain.

I've been meaning to add Oracle interface, but I couldn't find the
source for Oracle, and more importantly API documentations.

--
William Park <opengeometry@yahoo.ca>, Toronto, Canada
Slackware Linux -- because it works.
John L

2005-04-27, 2:48 am


"Chris" <ctaliercio@yahoo.com> wrote in message news:1114198523.851244.294970@f14g2000cwb.googlegroups.com...
> Does anyone know of a method, other than a sqlplus "here" document,
> that can be used to interact with Oracle from a UNIX shell?
>
> What I'd like to do is establish a connection and use it throughout the
> execution of a shell script in order to query and update the database.
>
> Using "here" documents to sqlplus can be quite expensive if the
> functions are executed often.
>
> I've considered using a co-process, but it seems that parsing the
> results to find out whether the command succeeded or not would be quite
> cumbersome.
>
> I also know that I could use Pro*C, but a lot of what I am doing in the
> shell script is somewhat of a PITA to incorporate within a C program.
> Much easier/simpler to use shell.
>
> Any thoughts from the group?
>


It is not really clear what you are trying to do and
you might do better asking in an Oracle newsgroup but
having said all that, I suspect the answer may well
involve PERL and its DBI modules (so try PERL groups).

So far as the shell itself goes, you can echo commands
to sqlplus, check its exit value to see whether commands
succeeded or not (within sqlplus you can do something
like: on sqlerror exit 96, or whatever value you like)
and assign the output of sqlplus commands to shell variables
or (more likely) shell arrays.

--
John.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com