Results 1 to 4 of 4

Thread: String Compare

  1. #1
    Join Date
    Feb 2004
    Posts
    37

    Unanswered: 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!

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    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.

  3. #3
    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

  4. #4
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •