All Forums Aster
swaroopkumarp 1 post Joined 03/14
26 Aug 2014
using a variable in aster teradata connectors

Hi,
   a>     How can I define a variable?
let’s say if I have a value which needs to be used in multiple load_from_teradata  SQL’s
i.e like variable X= value, 
if I need to run below kind of multiple queries , how can I achieve this?
           CREATE ANALYTIC TABLE ABC AS
SELECT * FROM load_from_teradata (
ON mr_driver
TDPID('dbc')
USERNAME('xxx')
PASSWORD('yyy')
QUERY ('select * from ABC where columnA > X'));
            CREATE ANALYTIC TABLE PQR AS
SELECT * FROM load_from_teradata (
ON mr_driver
TDPID('dbc')
USERNAME('xxx')
PASSWORD('yyy')
QUERY ('select * from PQR where columnA > X'));
 
 
 
b>Related to or extension of above question, can I use the result of an aster SQL inside the load_from_teradata query
In other words can I combine aster and teradata SQL’s in single statement, i..e use the result of aster to pull data from teradata .
i.e in above example let’s say X value has to be queried from the aster table , can we do this?

MikeDempsey 94 posts Joined 10/06
01 Jun 2016

It depends on what app you are using to run your queries.
Most apps have a way to specify a variable.
For example, in SQL Assistant you would use a 'named parameter' such as ?X.
The where clause would be
    where columnA > ?X
or
    where columnA > '?X'
depending on whether the value was numeric or character.
SQLA would ask you for the value (only one time even though it is used twice) whenever you execute the query.
 
 

You must sign in to leave a comment.