Home » Infrastructure » Unix » how to get oracle result in shell variable
how to get oracle result in shell variable [message #248460] Fri, 29 June 2007 02:13 Go to next message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
Hi,

i am just doing R&D. i have created fallowing shell.it is working fine.



# !/bin/ksh

##### Environment variables ######

export ORACLE_HOME="/opt/oracle/product/current"
export PATH=$PATH:$ORACLE_HOME/bin:/usr/local/bin:.
##################################


dbLoginStr="RAMSADM/welcome123@NPIDEV"

sqlplus $dbLoginStr  << EOT
select proj_id from ram_projects where rownum<2
/
EOT

exit;



can i get the proj_id value on shall variable.


--Yash
Re: how to get oracle result in shell variable [message #248470 is a reply to message #248460] Fri, 29 June 2007 02:39 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
> v=`sqlplus -s / <<EOF
> set echo off pages 0 feed off
> select * from dual
> /
> exit
> EOT
> `
> echo $v
X

Regards
Michel

[Updated on: Fri, 29 June 2007 02:39]

Report message to a moderator

Re: how to get oracle result in shell variable [message #248483 is a reply to message #248470] Fri, 29 June 2007 03:01 Go to previous messageGo to next message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
Thx Michel!! If query return multiple record or cursor..Then how ca I handle it ..


--Yash
Re: how to get oracle result in shell variable [message #248580 is a reply to message #248483] Fri, 29 June 2007 10:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Same way.
or
Precise your question.

Regards
Michel
Re: how to get oracle result in shell variable [message #248674 is a reply to message #248580] Sat, 30 June 2007 05:00 Go to previous messageGo to next message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
Hi Michel,

 v=`sqlplus -s / <<EOF
 set echo off pages 0 feed off
 [B]select empno from emp[/B]
 /
 exit
 EOT
 `
 echo $v
X



Now select query return more then one value. how can i get all these value on shell variable..


--Yash
Re: how to get oracle result in shell variable [message #248683 is a reply to message #248674] Sat, 30 June 2007 07:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
If you have tried it you'd see there are all values in the variable.
Now TRY it, POST what you get, WHY it is not you wanted and WHAT you want.

Regards
Michel
Re: how to get oracle result in shell variable [message #248688 is a reply to message #248683] Sat, 30 June 2007 08:02 Go to previous message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
Sorry michel i was not tried it ..it is working fine..

--Yash
Previous Topic: RAW device
Next Topic: Reading Properties file
Goto Forum:
  


Current Time: Fri Nov 22 04:12:36 CST 2024