Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: unix script

Re: unix script

From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: Thu, 20 Aug 1998 20:44:55 +0200
Message-ID: <6rhqpj$eeq$1@pascal.a2000.nl>


>I need to make Apples, Oranges, etc each it's own variable in the script.
Can
>I do this without writing 3 different select statements?

    set heading off
    set feedback off
    set verify off
    column apple noprint new_value my_apple     column orange noprint new_value my_orange

    select apple
    from apples
    where ...

    select orange
    from oranges
    where ...

    select &my_apple, &my_orange
    from dual;

Oh, that's not what you wanted to know. Well, maybe you can use it anyway. Try:

    result = $( sqlplus -silent user/password \@my_script )     echo "Result: ${result}"
    set ${result}

    echo "Parameter 1: ${1}"
    echo "Parameter 2: ${2}"
    echo "Parameter 3: ${3}"

If your apples and pears may contain spaces, add some unique delimiter, like

    select apples || '#' || oranges || '#' || pears     from my_table;

Now you can use the Unix cut command to get your parameters:

    result = $( sqlplus -silent user/password \@my_script )     echo "Result: ${result}"
    # -d specifies the delimiter; -f tells cut which field to extract:     param1 = $( echo ${result} | cut -d'#' -f1 )     param2 = $( echo ${result} | cut -d'#' -f2 )     echo "Parameter 1: ${param1}"
    echo "Parameter 2: ${param2}"

Arjan. Received on Thu Aug 20 1998 - 13:44:55 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US