Re: Referencing Unix vars with SqlPlus

From: Brian P. Mac Lean <brian.maclean_at_teldta.com>
Date: 1996/07/26
Message-ID: <31F93F9C.3423_at_teldta.com>#1/1


Dave Jensen wrote:
>
> Does anybody know of a way to reference Unix variables from within SqlPlus?
> I'd like to do this without having to pass them as parameters to the script.
> For example...
> Sqlplus /
> select '$unixvar' from dual;
>
> I know that the above syntax does not work, but is it possible? HOW???
>
> Dave Jensen
> Jensen Consulting
> djensen_at_ares.csd.net
>
> ><> Sheltie Fan and Oracle Database Consultant <><

This is UNIX, of course you can. I did this at the shell prompt but a script is the same. Hope it's what your looking for:

[UNIX:KSH]: export EXAMPLE=sysdate
[UNIX:KSH]: export TABLENAME=dual
[UNIX:KSH]: sqlplus -s / <<EOF

> select ${EXAMPLE} from ${TABLENAME};
> EOF

SYSDATE

26-JUL-96   [UNIX:KSH]: brian.maclean_at_teldta.com

"We trained hard, but it seemed that every time we were beginning to form into teams we would be reorganized. I was to learn later in life that we tend to meet any new sitiation by reorganizing, and what a wonderful method it can be for creating the illusion of progress while producing confusion, inefficiency, and demoralization."  

Petronius Arbiter 210 B.C. Received on Fri Jul 26 1996 - 00:00:00 CEST

Original text of this message