Parsing Comma Separated values to UNIX variable from PLSQL

Hi All,

I'm trying to pass the comma separated values (string) returned from Plsql Procedure to UNIX variable.

getting the below log message

cat: -: Bad file descriptor
awk: cmd. line:1: fatal: error reading input file `-': Bad file descriptor

The output coming from plsql procedure is abc@xyz.com,def@xyz.com,ghi@xyz.com and need this string to pass to the mail to address further in the code.

Below is the code.

LOG_FILE=$FCP_REQID.txt
echo 'Logfile is :'$LOGFILE
output_var=''
sqlplus -s /nolog  <<ENDSQL|grep -v 'Connected'>$LOG_FILE
connect $FCP_LOGIN
set feedback off
set heading off
set serveroutput on
declare
mavar1 varchar2(400);
begin
pack_list_print_pkg.get_cust_mail_address($param1,$param2,mavar1);
dbms_output.put_line('CUSTMAIL-ADDRESS'||mavar1);
end ;
/
ENDSQL
cat $LOG_FILE
customer_mail_address=`awk '/CUSTMAIL-ADDRESS/ {print $2}' $LOG_FILE`

echo 'customer mail address is :'||$customer_mail_address

Hi Mahesh,

Can you post the output of below command:

sqlplus -s /nolog <<ENDSQL|grep -v 'Connected'>$LOG_FILE
connect $FCP_LOGIN
set feedback off
set heading off
set serveroutput on
declare
mavar1 varchar2(400);
begin
pack_list_print_pkg.get_cust_mail_address($param1,$param2,mavar1);
dbms_output.put_line('CUSTMAIL-ADDRESS'||mavar1);
end ;
/
ENDSQL

Output of the command

cat: -: Bad file descriptor
 awk: cmd. line:1: fatal: error reading input file `-': Bad file descriptor

You were asked to show the output of the SQL command without the cat and awk commands that follow it in your original post. I would also be interested in the value of the variable $FCP_REQID.txt

And as the mods ask, please use the code tags to separate out your listings and output from the rest of the text.

Andrew

2 Likes