The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
oracle connection from shell script DILEEP410 Shell Programming and Scripting 4 07-01-2009 03:19 AM
Oracle database connection pools setting skully Oracle Updates (RSS) 0 06-02-2008 04:04 AM
Oracle 9i ODBC connection jkuchar747 Windows & DOS: Issues & Discussions 3 04-15-2008 03:10 AM
unix to unix serial connection question typsam IP Networking 1 10-17-2002 05:39 PM
shell script- oracle connection problem nattynatty Shell Programming and Scripting 4 08-14-2002 10:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-03-2006
decci_7 decci_7 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 17
Unix + oracle connection

Requirements:

Using a shell script I have to check the 4 values from a table in Oracle and then store the result as "Y" in a Unix variable if the values are desired and "N" if the values are not desired.

Explanation:

There is a table abc in oracle which has 4 fields. if all the four values comes out to be 1 then i want to assign a Unix variable "result" as "Y".

If even one of the values is "0" then i want to assign the UNIX variable "result" as "N".

All this has to be done using UNIX shell scripting.

Request the experts to come ahead and help me.

Decci
  #2 (permalink)  
Old 12-03-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,808
One way -

Code:
sqlplus -s username/passwd@oracledb<<EOF
set head off
set feedback off
spool tmp.tmp
select fld1 + fld2 + fld3 + fld4 from abc;
spool off
exit
EOF
result=0
grep -q '4' tmp.tmp
if [[ $? -eq 0 ]] ; then
  result=1
fi

  #3 (permalink)  
Old 12-04-2006
kapilraj kapilraj is offline
Registered User
  
 

Join Date: Dec 2006
Location: Maryland
Posts: 162
jim, would it not print wrong if the values were 4,0,0,0 ?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0