Question

Asked on 2000-11-08 at 04:53:05ID: 25483503

How to use Unix environment variable in a SQL query

by: pyxos50

Rating8.0Very Good

Hi,

I would like how to retrieve the value of an environment variable to use it in a SQL statement defined in testvarenv.sql and run when called in the file testvarenv.sh.
I know that the solution could be to insert the SQL statement in the Shell script, but I don't want to do this.

The files are described below.

Thanks in advance,
Pyxos

testvarenv.sql
--------------
delete from DESCRIPTIONS where description_code = 32000;
insert into DESCRIPTIONS (description_code, description_text, language_code, description_group) values (32000, $ARBORDIR || '/test', 1, 0);

testvarenv.sh
-------------
#!/bin/ksh

if [ $# -ne 3 ]
then
      echo "\n You need to provide the user, password and database names."
      echo "\n e.g. encapsulation.sh user password database\n"
      exit -1
fi

USER=$1
PASS=$2
DATABASE=$3


sqlplus $USER/$PASS@$DATABASE  << THEEND

@testvarenv

commit;

exit

THEEND

echo "Configuration done."

  1. oracle-unix
    In unix -how u will connect to ur oracle database?
  2. Unix basics
    How to switch from SQL> to $ prompt and back to SQL> in unix where I am working on oracle verion 9i.
  3. how to do logical operations in sql
    how to do logical operations in sql something like select (nvl(null,0) != nvl(null,1)) from dual. why doesn't this query work? please give the alternative for this.
  4. How to PL/SQL  code though  browser.
    We are using Oracle Application server as middle tier, would like to test how we can execute the PL/SQL block of code through browser and how we can restrict the same
  5. how to write ' or " around a passing-in variab…
    Have a PL/SQL statement like EXECUTE IMMEDIATE 'select username from dba_tables where table_name = upper(aTable)' into v_tablename; aTable is a variable that is passed in. Thancompiler complains the aTable. I tried 'aTable' , ''aTable", '''aTable'''. None of them worked. Please help.

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution
View This Solution - Start Your 30 Day Free Trial
Zone
General
Tags
sqlplus how ksh query variable
Participating Experts
2
Solution Grade
A

Replies

 by: sbenyo

Posted on 2000-11-08 at 05:27:29ID: 28375508

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by:

Posted on 2000-11-08 at 06:50:49ID: 28375509

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: pyxos

Posted on 2000-11-08 at 11:13:19ID: 28375510

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Stay Connected

Oracle Around the Web

The latest Oracle news, tips, and tricks

Oracle Unveils Netra SPARC T3 Servers

New Carrier-Grade Blade and Rackmount Servers Deliver Better Performance, Density and Power Efficiency for the Communications Industry ...

read more

Oracle fixes 21 flaws in Java SE, Java for Business

Oracle is fixing 21 flaws in its Java SE and Java for Business products in its February critical patch update issued this week ...

read more

Obama’s Silicon Valley “Tech Supper”

Why was he there? Who wasn’t invited and why? What did they talk about? Why was he really there? These are the questions being debated ...

read more

Featured Oracle Experts

slightwv

slightwv has answered more than 2,000 Oracle questions and oversees database management within the U.S. Government. Slightwv

sdstuber

A regular presenter at the Collaborate conference, Oracle developer sdstuber is a top expert in PL/SQL and Oracle 9, 10 and 11. sdstuber

Testimonials

What users are saying about our experts

"The Oracle gurus provide answers, solutions and valuable workarounds"

User: schwertner

"Wow! Excellent, valuable explanation. Hats off to you"

User: aseshu70

"Solution worked fantastic and performs excellent! Thanks heaps"

User: klausbrandlhuber

Top Experts

  1. slightwv

    2,000

    0 points yesterday

    Profile

BrowseBecome an Expert