The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question, sanjeev.
Asked: April 12, 2017 - 7:42 am UTC
Last updated: April 13, 2017 - 3:32 am UTC
Version: 1
Viewed 1000+ times
FILE_VAR="test" runforfile() { echo -n "Select 1 for Interim FX and 2 for Final FX :" read File_Optn } #/* Log into ORACLE to execute command */ runSql() { FILE_VAR=`sqlplus -s ufad00/$ORA_UFAD00@$INSTANCE << EOF | tee -a ${CurrentLogFile} set serveroutput on declare exception_str VARCHAR2(32767); f_name varchar2(20); begin IF ($File_Optn > 2 OR $File_Optn < 1) THEN dbms_output.put_line('Entered value $File_Optn is incorrect option.'); return; END IF; UFAD00.sp_IFX_ForexData($File_Optn, f_name, exception_str); dbms_output.put_line(f_name); dbms_output.put_line(exception_str); end; / EOF` }
[oracle@vbgeneric ~]$ cat x #!/bin/ksh print " set serveroutput on set feedback off begin if '$1' = 'ok' then dbms_output.put_line('RESULT'); else raise_application_error(-20000,'Aggghhhhh'); end if; end; / " | sqlplus -s mcdonac/alicat1 1>/tmp/output 2>&1 if [ "`grep 'ORA-' /tmp/output`" ] ; then echo SOMETHING WENT WRONG: cat /tmp/output else FVAR=`cat /tmp/output` echo "FVAR=$FVAR" fi [oracle@vbgeneric ~]$ ./x ok FVAR=RESULT [oracle@vbgeneric ~]$ ./x bad SOMETHING WENT WRONG: begin * ERROR at line 1: ORA-20000: Aggghhhhh ORA-06512: at line 5
More on PL/SQL routine DBMS_OUTPUT here