title: Unconditional bash exit after receiving exit code other than 0 from BTEQ
body: <p>I have a simple bash script with following bteq;</p>
  
  <pre><code>bteq &lt;&lt;EOF!
      .set width 255
      .set format off
      .set titledashes off
  
      .logon ${HOST}/${USER}, ${PASSWORD};    
  
      .export report file=test_file.rpt;
  
      SELECT count(*) from test_db.test_table;   /*this table contains 90 rows in my case*/
  
      .IF ERRORCODE &lt;&gt; 0 THEN .EXIT ERRORCODE;        
      .IF ACTIVITYCOUNT = 0 THEN .GOTO ALLOK
  
      .LOGOFF;
      .EXIT 3;
  
      .LABEL ALLOK;
      .LOGOFF;
      .EXIT 0;
  
  EOF!
  
  /*Now if the above bteq returns 0,(i.e. RET_FLAG = 0) the below code executes 
  with RC (return code) = 0 but if it returns values other than 0 below code doesn't executes and finally bash exits.*/  
  
  RET_FLAG=$?   
  print_msg "RET_FLAG: $RET_FLAG "   /*when return code other than 0 this line is not printed*/
  
  if [ $? -gt 0 ];
  then
       print_msg "Hello world get succeed" /* printing function */
       exit 1
  fi
  </code></pre>
  
  <p>I have worked whole day to figure out, but still no progress. Help from anybody out there would save my night.Thanks in advance.</p>