Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 15 May 2013 @ 19:50:52 GMT


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


Subj:   Can I use variables in SQL Assistant?
 
From:   DUELL, BOB

Hi,

In SQL Assistant, is there a way to define a variable in such a way that its value is used in a query?

I know I can use a "prompt" to get one value, but is there a way to use that same prompt more than once?

As a trivial example, suppose I want to list all the tables in two databases that were created by a given user. I want to do something like this:

     select *
     from   DBC.TABLES
     where  DatabaseName = 'my_db1'
       and CreatorName = ?target_id /* Prompt for user ID */
     union
     select *
     from   DBC.TABLES
     where  DatabaseName = 'my_db2'
       and CreatorName = @target_id /* Use same value from previous prompt */

I also know this could be done with a macro, but I don't have "CREATE MACRO" permission.


Thanks!

Bob



     
  <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