Archives of the TeradataForum
Message Posted: Wed, 25 Feb 2003 @ 20:48:57 GMT
Bteq is also capable of both the conditional logic (albeit at a basic level) that you ask for and returning a status code to the calling process. Here is an example from a data model generation process of mine. It attempts (in this case) to drop a macro and check for various error conditions. Depending on the result it will write a record out to a file. The file is read by a separate process that examines and reports on what actually happened. The second and third example shows how you might abort on errors.
drop macro get_proc_day_n_cell_type; /* 3824 - macro doesn't exist - consider this to be a success - ** even though someone else has beaten us to it the result is still the same */ .if errorcode = 3824 then .goto SUCCESS .if errorcode <> 0 then .goto ERROR .label SUCCESS .os echo d:m:get_proc_day_n_cell_type:S >> gendm.dat .goto NEXT_STMT .label ERROR .os echo d:m:get_proc_day_n_cell_type:F >> gendm.dat .label NEXT_STMT
drop macro get_proc_day_n_cell_type; .if errorcode <> 0 then .quit 999
.set maxerror 1 drop macro get_proc_day_n_cell_type;
I will leave it to you to read the bteq manual for a description of the commands I have used.
Just in case you are interested, the first example is part of a larger process that manages the creation and destruction of database objects (tables, views, macros etc). The larger process is written in perl and the snippet in example 1 is entirely generated by the perl script and fed into bteq in real time as it is being generated. This is akin to the batch processing you are asking for with error checking you need.
BTW. You can find the manuals at www.ncr.com click library, then technical publications, then Teradata data warehouseing
|Copyright 2016 - All Rights Reserved|
|Last Modified: 28 Jun 2020|