Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 23 Oct 2015 @ 09:23:58 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   Capturing BTEQ return code and logging output simultaneously
 
From:   Anomy Anom

<-- Anonymously Posted: Thursday, October 22, 2015 01:25 -->

Hi,

I want bteq output to be displayed on stdout and also be logged to a file using unix 'tee' command. Also I intend to check the bteq return code and take necessary action.

Here is the code snippet -

     *****************************************************
     bteq << EOF | tee bteq_log_file
     .logon td1/user1,passwd;
     select count(*) from table;
     .IF errorcode <> 0 .GOTO ERROR;

     .LABEL ERROR
     .QUIT 99
     .LOGOFF
     .QUIT
     EOF

     RETURN_CODE=$?

     if [ $RETURN_CODE -ne 0 ]
     then
     exit $RETURN_CODE
     fi
     *****************************************************

When bteq throws an error the return code check below is not working because it is in effect evaluating the return code of the 'tee' command (which is the last command to be executed after bteq) and not evaluating the return code of the bteq, which executes before 'tee'.

Is there any way to circumvent this problem ? I want to display the output of bteq on stdout and redirect to a file and also check the return code of bteq (and not that of tee).


Please advise.

Thanks



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023