Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: user variables and bind variables in sqlplus

RE: user variables and bind variables in sqlplus

From: William Rogge <William_Rogge_at_voltek.com>
Date: Mon, 27 Nov 2000 17:06:24 -0500
Message-Id: <10693.123008@fatcity.com>


I do it all of the time. What I do is set up my UNIX script to set a variable equal to the inline code of the sqlplus command. Something like this.

the_date=`sqlplus -s username/password <<EoI set pagesize 0 echo off verify off feedback off select to_char(sysdate,'DD-MON-YYYY') from dual; exit
EoI`

The << is considered a DOCUMENT file and takes all lines until a line beginning with the label (EoI in this case) is encountered. Since I used gravee characters, the sqlplus command is executed inline. The sql code generates a single value (per the formatting) which is all that is echoed from the sqlplus command. That echo in turn is loaded into the environment variable 'the_date'. From there, I can use the date anywhere in my shell script.

I hope this helps you.

-----Original Message-----

From:	Adams, Matthew (GEA, 088130) [SMTP:MATT.ADAMS_at_APPL.GE.COM]
Sent:	Monday, November 27, 2000 3:00 PM
To:	Multiple recipients of list ORACLE-L
Subject:	user variables and bind variables in sqlplus

I'm using sqlplus 3.2.3 and pl/sql 2.2.3 (the versions that came with rdbms 7.2.3) and I'm stuck.

I need to get a result from a select statement and return it to the unix shell script environment.

Getting the result into a bind variable is a relatively trivial excersice, but in this version of sqlplus, the quit command does not accecpt a bind variable argument, only a user variable arguement.

I can't figure it out. Anybody done this with this relatively old software?



R. Matt Adams - GE Appliances - matt.adams_at_appl.ge.com   It will make sense when you stop thinking logically   and start thinking Oracle-ly - Jim Droppa
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Adams, Matthew (GEA, 088130)
  INET: MATT.ADAMS_at_APPL.GE.COM
Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Mon Nov 27 2000 - 16:06:24 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US