• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

Output parameter

Hi everybody,
           i had a shell script which connects to the oracle Db and gets the maximum date from the table i want to store this in a variable and to pass to the calling program. can anybody help me


select max(creation_date) from table name

i want to store that value in a vairable.


thanks
sri
0
parsi_cnu
Asked:
parsi_cnu
2 Solutions
 
neteducationCommented:
Not completly ure how you mean it....

a=`sqlplus user@database/password <<EOF
select max(creation_date) from table name;
EOF`

Like this you have the entire session output in $a and you can filter out the info you need


or (if you already have that script that gives you just the output you want) then

a=`yourotherscript`


0
 
myrizviCommented:
Hi,

Try this :

var=`sqlplus -s <username>/<passwd> <<SQL_EOF
        set heading off
        set feedback off
        select to_char(max(creation_date),'dd-mon-rr') from table_name;
        exit;
        SQL_EOF`

echo $var

You can also write the above code in a seprate script file like,    get_dbdate.sh and then in calling program (I assume its a shell script as well) write:

dbdate=`get_dbdate.sh`

Cheers :)
0
 
GnsCommented:
myrizvi, note that your example is flawed in that the here document is unterminated. Never "prettyfy" by indenting a here doc.
Good thought on shutting sqlplus up a bit though.

-- Glenn
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now