I am experiencing a sporadic problem with BTEQ skipping all the commands from STDIN.
The script is a shell script that does a bunch of set up and then calls BTEQ, piping in the commands that are in the same file.
Here's my script (at least part of it):
# ----------------------------- Execute the main script-----------------------------------
echo "<--------- BTEQ: START ----------> "
echo
bteq<<-[EOF] > ${LogDir}/${Bteq_Log}
.SET SESSIONS 1;
.SET WIDTH 254;
.SET ERROROUT STDOUT;
.SET ERRORLEVEL (0, 2641) SEVERITY 0;
.SET ECHOREQ ON;
.SET RETCANCEL ON;
.SET RETLIMIT 20;
.run file=${MAIN_DIR}/logon_BTEQ_EIS.txt;
.IF ERRORCODE != 0 THEN .quit ERRORCODE;
...
.QUIT 0
[EOF]
For a normal run, the log file looks like this:
BTEQ 12.00.00.04 Thu Jun 30 14:02:19 2011 +---------+---------+---------+---------+---------+---------+---------+---- .SET SESSIONS 1; +---------+---------+---------+---------+---------+---------+---------+---- .SET WIDTH 254; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .SET ERROROUT STDOUT; *** Error messages now directed to STDOUT. +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .SET ERRORLEVEL (0, 2641) SEVERITY 0; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .SET ECHOREQ ON; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .SET RETCANCEL ON; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .SET RETLIMIT 20; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .run file=/xfer/BMP/extracts/TERADATA/bteq-scripts/eis/logon_BTEQ_EIS.txt; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .logon TeraProd/BTEQ_EIS, ... .QUIT 0 *** You are now logged off from the DBC. *** Exiting BTEQ... *** RC (return code) = 0
When things go wrong, it looks like this:
BTEQ 13.10.00.06 Wed May 1 23:12:43 2013 +---------+---------+---------+---------+---------+---------+---------+---- *** BTEQ exiting due to EOF on stdin. *** Exiting BTEQ... *** RC (return code) = 0
You can see that it doesn't even execute the very first statement after calling BTEQ. I haven't been able identify what is cuasing the problem so I can fix it.
More important, though, is that I detect when this happens so we can take corrective action. Unfortunatley, BTEQ exits sucessfully in this case. What I'd like to do (if possible) is to specify that reaching the EOF without logging off BTEQ first results in a non-zero return code.
Does anyone know if this can be done (changing the return code)? One thing I considered was setting the RC to a non-zero value right ways, but the fact that we don't even execute the first statment seems to make that impossible. I'm not sure there's a way to do that anyway.
I'm also open to any other ideas for detecting this situation.
Thanks,
Jimmy