|
-
To take some value from the database and put it into your variable in your unix script you can do the following;
For example in your unix script write;
/oracle/bin/sqlplus "/as sysdba" @yoursqlscript.sql
-In your sql script
use ;
spool /textfile.txt in the beginning and
use;
spool off after the line which you get the value of whatever you wanted from the database;
For ex :
spool /textfile.txt
select value from numbers where number=1;
spool off;
Now ,you have 1 in your textfile.Then use "cat" or awk with the textfile to take the needed value written in the textfile and put it into your unix script variable.
This is a solution for this.
then use this;
a=`cat textfile.txt | awk '{print $0}'`
echo $a
so you got 1 in your unix variable a .
If you have a big query which returns a lot of columns,you can use awk command to take specific values from any line,any word,etc.. of a textfile
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|