Total Pageviews

Tuesday 29 October 2013

Sample Bteq Script

exec 1>/LogPath/logs/`echo $0 | cut -d '/' -f8 | sed 's/\.sh//g'`_$(date +"%Y%m%d_%H%M%S").log 2>&1
bteq <<EOF
.SET WIDTH 150;
.SET SESSION TRANSACTION BTET;
.run file LOGON_ID;
SELECT SESSION;
SET QUERY_BAND ='ApplicationName=$0;Frequency=Daily;' FOR SESSION;
DATABASE DB_NAME;
.IF ERRORCODE <> 0 THEN .GOTO ERRORS
SQL Query;
.IF ERRORCODE <> 0 THEN .GOTO ERRORS
.QUIT 0
.LABEL ERRORS
.QUIT ERRORCODE
EOF
RETURN_CODE=$?
echo " script return code= " $RETURN_CODE
exit $RETURN_CODE

1 comment:

  1. hey nice post meh, You are one of the best writers I've seen of recent. I love your style of blogging here. this post reminds me of an equally interesting post that I read some time ago on Daniel Uyi's blog: What's Extraordinary About Gurus? .
    keep up the good work friend. I will be back to read more of your posts.

    Regards

    ReplyDelete