1) Alternative 1
Create an empty file before you run the bteq(or we can use OS command to touch a empty file)
And write the bteq script as below:
Create an empty file before you run the bteq(or we can use OS command to touch a empty file)
And write the bteq script as below:
.logon tdpid/username,password;
.OS if [ -f bteq_restart_step.txt ]; then else {touch bteq_restart_step.txt};
.run file bteq_restart_step.txt;
.label sql1;
DML statement1
.if errorcode <> 0 then .goto EXIT_ERROR;
.if errorcode = 0 then .os echo '.goto sql2' > bteq_restart_step.txt;
.label sql2;
DML statement2
.if errorcode <> 0 then .goto EXIT_ERROR;
.if errorcode = 0 then .os echo '.goto sql3' >bteq_restart_step.txt;
.label sql3;
DML statement3
.if errorcode <> 0 then .goto EXIT_ERROR;
.if errorcode = 0 then .os echo '.goto sql4' > bteq_restart_step.txt;
.label sql4;
DML statement4
.os rm -f bteq_restart_step.txt;
.quit 0;
.label EXIT_ERROR;
.quit 99;
If the script completes sql1 and fails in the statement sql2 then the the file bteq_restart_step.txt will contain '.GOTO SQL2'. So when we restart the script it will run the '.run file' command and jump to the previously failed step.
2) Alternative 2
Create a wrapper script that will accept step number from the user and then change the bteq_restart_step.txt with appropriate stepnumber from where it has to be started.
3) Alternative 3
Create a multistatement request as follows:
DML statement1
;DML statement2
;DML statement3
This will create a transaction and hence it will either run completely or wont run itself.
In this case you wont have to worry about the restart. Just submit the script again.
No comments:
Post a Comment