![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SQLPLUS unable to execte query automatically from solaris script | jyotisree | SUN Solaris | 2 | 08-11-2008 03:03 AM |
| Oracle Query results to be stored in variables | ashokjaysiv | Shell Programming and Scripting | 1 | 03-24-2008 01:37 AM |
| SQLPLUS and update statements using bind variables | Nomaad | UNIX for Advanced & Expert Users | 3 | 08-19-2007 12:55 AM |
| sql query results in unix shell script | skyineyes | UNIX for Dummies Questions & Answers | 1 | 06-20-2007 07:56 AM |
| How to pass Shell variables to sqlplus use them as parameters | Jtrinh | Shell Programming and Scripting | 1 | 07-13-2005 01:15 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi All,
I needed to get the result of two sqlplus queris into shell variables. After days of looking for the ultimate solution to this problem.. i found this... Code:
sqlplus -s USER/PASS@DB <<EOF | awk '{if(NR==1) printf("%s ", $1); if(NR==2) printf("%s ",
$1);}' | read VAR1 VAR2
set head off pagesize 0 echo off verify off feedback off
select name from v$database
/
select log_mode from v$database
/
EOF
I did not understand the logic used in the above peice of code. As far I was concerned, my objective was achieved. But then I saw perils of under-understanding! Knowledge shouldn't be a mission, it should be a journey! The problem I am facing now is that, I now need to get just one value out of the sqlplus connection. So, i just simply tried.. Code:
sqlplus -s USER/PASS@DB <<EOF | awk '{if(NR==1) printf("%s ", $1);' | read VAR1
set head off pagesize 0 echo off verify off feedback off
select name from v$database
/
EOF
Thanks! Pranav |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Try this:
Code:
var=$(sqlplus -s USER/PASS@DB <<EOF | tail -1 set feedback off; select name from v\$database; EOF ) |
|
#3
|
||||
|
||||
|
Or:
Code:
dbname=$(sqlplus -s '/ as sysdba'<<\! set pages 0 feed off select name from v$database; ! ) Code:
printf -vdbname 'set pages 0 feed off\nselect name from v$database;' | sqlplus -s '/ as sysdba' Last edited by radoulov; 09-01-2008 at 11:32 AM. |
||||
| Google The UNIX and Linux Forums |