Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 17 Apr 2002 @ 13:48:41 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Examples for a beginner
 
From:   Jim Downey

I use a primitive brute force method to do something similar to what you describe. Most of what I do uses the DBC tables as input to generate redundant SQL.

Assuming your prepopulated table (T1) has three columns (C1,C2,C3), suppose C1 contains the name of a table you want to read, C2 contains the name of a column and C3 contains a value within another column you want to check and you only need one row from the table to provide your variables then you can write something like:

select
(
'select '||
''''C2''''||
'from '||
''''C1''''||
'where Another_Column='||
''''C3''''||
';'
) as XQL
from T1
;

The code outside the parenthesis reads every row in your prepopulated table replacing C1,C2 and C3 with the values in those columns. The result set is a row of SQL for every row in your prepopulated sql. I usuallly copy/paste the rows into queryman and run the code but you can also write it to another file that is then called by bteq.

The sets of four quotes is needed to surround the contents of your columns with quotes. If your column is numeric then they are not needed. The double vertical lines concatenate each row into a single column (which is later named XQL)

Jim



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023