Re: urgent help needed!! - connecting to db through unix script

From: Alan D. Mills <alanmNOSPAM_at_uk.europe.mcd.mot.com>
Date: 1998/03/17
Message-ID: <01bd51ae$48b5df40$73d0658c_at_ukmhdam>#1/1


Maybe try sometning like this::

Have a SQL script which writes dynamic shell code, say,

SPOOL myshellscript.sh
SELECT 'export MYENVVAR1=' || col1||CHR(13) , 'export MYENVVAR2=' || col2||CHR(13)
FROM Mytable
/
spool off
quit

You'll need to ensure your formatting but what you'll get out of this is a shell script which reads something like

export MYENVVAR1=hello
export MYENVVAR2=world

or similar.

-- 
Alan D. Mills

To email remove NOSPAM from address.

You're shell script could then work as follows


sqlplus -s uid/pwd_at_SID @mysqlscript.sql
. myshellscript.sh

by now the environment var should be set.

you might have to play with this a little but it should get you going in
the right direction.

Alan

WayneB <Wayne_Leone_at_notes.amdahl.com> wrote in article
<Epwqv2.C8r_at_ccc.amdahl.com>...

> Hi all,
>
> This is someting I need to solve as soon as possible.
>
> From unix shell script I need to
>
> 1. Connect to a database
> 2. Retrieve values from a table
> 3. For each value, assign to an environment variable.
> 4. Close connection
>
> When the scripts finishes, I need to be able to see the environment
> variables
> by doing 'set' or 'env' (doesn't matter which one just so long as I can
see
> the values
> from the command prompt).
>
> Thanks in advance.
> Wayne Leone
>
>
>
Received on Tue Mar 17 1998 - 00:00:00 CET

Original text of this message