If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > String Compare

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-18-04, 11:59
gomes009 gomes009 is offline
Registered User
 
Join Date: Feb 2004
Posts: 37
String Compare

I have a database procedure with some out parameters(all of them are VARCHAR2(STRING)).

Here is how I am storing the out parameters returned by the database procedure

set -A file_var
${file_var[0]}
${file_var[1]}
${file_var[2]}
${file_var[3]}
${file_var[4]}
${file_var[5]}

set -A file_var `$ORACLE_BIN/sqlplus -s UN/PW@SID @pass_out.sql`
print ${file_var[0]} ${file_var[1]} ${file_var[2]} ${file_var[3]} ${file_var[4]} ${file_var[5]}

var0=${file_var[0]}
var1=${file_var[1]}
var2=${file_var[2]}
var3=${file_var[3]}
var4=${file_var[4]}
var5=${file_var[5]}

echo $var0
echo $var1
echo $var2
echo $var3
echo $var4
echo $var5

The column values from the database are displayed.

Everytime I run the shell script it executes the db procedure and returns the values to the variables.

I have created couple other variables

PROCESS_LOAD='LOAD'
PROCESS_COUNT='COUNT'

QUESTION:

I am trying to compare the value in $var4 with $PROCESS_LOAD. IF the strings matchup, I want to run DATA LOADER process.

Similarly, when I run the shell script next time, I want to compare the value in $var4 with $PROCESS_COUNT. If the strings matchup, I need to call the COUNT PROCESS.

Any help is appreciated!
Reply With Quote
  #2 (permalink)  
Old 02-18-04, 13:30
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Code:
set -A file_var `$ORACLE_BIN/sqlplus -s UN/PW@SID @pass_out.sql`
if [ "${file_var[4]}" = "$PROCESS_LOAD"  ]
then
   #run DATA LOADER process
fi
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-18-04, 16:39
gomes009 gomes009 is offline
Registered User
 
Join Date: Feb 2004
Posts: 37
Re: String Compare

Jean

Thanks for your help! It works.

I am trying to test the same for two different conditions.

If the value of ${file_var[4]} = $PROCESS_LOAD
I am calling the LOAD process (1st process). It works.

But If the value for ${file_var[4]} = $COUNT then I am comparing the count of records in two differnt files. If the count matches then call the COUNT process(2nd Process), if the counts don't match then call the ERROR process.

Any help is apprecaited
Reply With Quote
  #4 (permalink)  
Old 02-19-04, 10:23
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
I'm not sure to understand what you want to do, perhaps :
Code:
set -A file_var `$ORACLE_BIN/sqlplus -s UN/PW@SID @pass_out.sql`
if [ "${file_var[4]}" = "$PROCESS_LOAD"  ]
then
   #run DATA LOADER process ... set file_var array
   if [ "${file_var[4]}" = "$COUNT"  ]
   then
      #call the count process
   else
      #call the errotr process
   fi
fi
or
Code:
set -A file_var `$ORACLE_BIN/sqlplus -s UN/PW@SID @pass_out.sql`
if    [ "${file_var[4]}" = "$PROCESS_LOAD"  ];then
   #run DATA LOADER process ...
elif [ "${file_var[4]}" = "$COUNT"  ];then
   #call the count process
else
   #call the error process
fi
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On