Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 21 Aug 2007 @ 20:26:55 GMT


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


Subj:   How to run the Select SQL generated as a result of a SQL in Macro or Procedure
 
From:   Matkar, Ankit

Hi ,

I have a requirement where I need to run one SQL the o/p of which is a again a SQL statement. I need to submit the O/p again as a query and pass the reulst to the user. I have to do this using a ODBC connection for a front end application.

For example :-Consider a query of the form

     SELECT 'SELECT * FROM MARKETING_DB.'||TRIM(TABLENAME)||';' FROM
     DBC.TABLES
     WHERE DATABASE_NAME='MARKETING_DB'
     And CREATETIMESTAMP=(SELECT MAX(CREATETIMESTAMP) FROM DBC.TABLES
                             WHERE DATABASENAME='MARKETING_DB');

So O/p may be something like

     SELECT * FROM MARKETING_DB.ABCDEFG;

SO this O/p needs to be run again and the results needs to be presented to the user.

This is a oversimplified version of my problem which can be easily solved by parameterizing. But for me the o/p of first SQL is a SQL with many unions and where clauses which are created on fly.

Any help on this would be appreciated.


Thanks,

Ankit Matkar



     
  <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: 27 Dec 2016