Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: unix script
>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
![]() |
![]() |