All Forums Teradata Applications
gbansal 18 posts Joined 02/11
18 Jun 2014
How to Pass mutliple values from text file to parametrized bteq

Hi ,
i have extracted below two records in a file
Start_Date     End_Date
2014-01-01    2014-06-30
2014-07-01    2014-12-31
 
i am pasing this a query now
select * from tablename where Start_Date = {Start_Date}
and End_date = {End_Date}
Earlier i was passing only one row but now i am passing two values
When i execute this bteq , the sql which run is as below
select * from tablename where Start_Date = '2014-01-01    
2014-06-30'

and End_date = '2014-07-01    
2014-12-31'
Can you please tell how i can make it as IN End_date IN some thing like that or there is any other way i can pass multiple values to paramterized bteq
 

 

Raja_KT 1246 posts Joined 07/09
18 Jun 2014

If I understand you correctly.

You can think of a unix script, running a loop(for,while,do while). Inside a loop, do a readline.

Extract or cut  the first field start_date delimited by a space and put in your sql script accordingly.So also for the end_date. So your bteq script is inside a unix loop.

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

gbansal 18 posts Joined 02/11
18 Jun 2014

Thanks alot Raja!
Can we in a way so that i can pass all values to variable in one go and we can use IN operator in sql
select * from tablename where Start_Date in ( {Start_Date1} ,{Start_Date2});
something like that .

Raja_KT 1246 posts Joined 07/09
18 Jun 2014

Very much you can do that. You can assign the entire thing to a variable and use that as parameter. For ease of testing, use echo and see the output, whether it conforms to SQL syntax properly or not and then implement it.

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

You must sign in to leave a comment.