BTEQ - conditional branching


Re: BTEQ - conditional branching

Yes that will work.


However I wasn't clear. There is existing BTEQ (SQL) going against several Teradata tables.

'87' are now being populated onto these various tables.

So, the Teradata tables would now have '48, '83, '84' as well as '87'.

However, we don't want any of the '87' rows to be processed on any of the teradata tables.

I could code like your suggestion, however that would involve many updates statements to several teradata tables.

Instead, I would like to at the begining of the BTEQ (sql) bypass ALL '87' quit, then allow the '48', '83' & '84' to process / flow thru rest of BTEQ (sql) which involves updates to several teradata tables.


anymore feedback??


Re: BTEQ - conditional branching



Sorry but I don't think you can do that, this isn't how SQL works. When you execute an SQL statement against a table it will process all rows that meet the selection criteria.


If a table contains some rows that you want to process with a particular SQL statement and some that you don't, then you have to code the WHERE clause in that SQL statement so that only the required rows are processed.


If you have multiple SQL statements against multiple tables which only need to process some rows on each table, then each SQL statement must be coded to only process the required rows.


So I think you have to change the code on every SQL statement to only process the 'non 87' rows. What I think you have to code is something like:

UPDATE table_1
  SET column_x = column_x + 1
WHERE SUBSTR(SRC_ACCT_NB,1,2) IN ('43','83','84');

UPDATE table_2
  SET column_y = column_y + 2
WHERE SUBSTR(SRC_ACCT_NB,1,2) IN ('43','83','84');

And yes you may have to make changes to lots of SQL statements, but (as I said) I don't see any other way of doing this. SQL works on 'sets of rows' and without any selection criteria the 'set' is all rows in the table.





Ward Analytics Ltd - information in motion

Re: BTEQ - conditional branching

Yes this confirms what I was finding out with some preliminary testing.

Thanks for your suggestions & feedback.

Teradata Employee

Re: BTEQ - conditional branching

For a detailed explanation of writing logic that works on sets of rows, see my blog entries.  The topic is "Learning to Think in Set SQL," and it proceeds from introducing the basic concepts of set logic to examples that apply in most cases, then to more complex examples of converting loop logic to SQL's set logic.