All Forums Database
07 Oct 2014
View with a dynamic table in FROM clause (without using Java or C)?

Hi all,

could you help me with the following question?

I would like to deliver a table to a view based on the given query band value for variable "Language":

Is it possible to implement this logic somewhere in Teradata without using Java or c?
I got stuck whith UDFs when reading this: write-a-table-valued-function-in-teradata


07 Oct 2014

Here is the logic I would like to apply (it got lost in the original post):
WHEN GetQueryBandValue(0,'Language') = 'French'  THEN SELECT * FROM myTable_French
WHEN GetQueryBandValue(0,'Language') = 'English' THEN SELECT * FROM myTable_English

Raja_KT 1246 posts Joined 07/09
07 Oct 2014

As far as I know , it cannot be done, query band test and then do a select..... :)
Let us hear from other who may have done this.
In sql udf, only simple test we can do ....I think.

Raja K Thaw
My wiki:
Street Children suffer not by their fault. We can help them if we want.

tomnolan 594 posts Joined 01/08
07 Oct 2014

I assume that these tables contain error messages, or some other kind of text that is displayed for the user?
It would be simpler to use a single table, and distinguish each row in the table with a language code. I strongly recommend combining the tables together.
However, if you cannot permanently combine the tables for some reason, you can create a view that simulates the tables being combined. Using a view like this may be lower performance that if the tables were actually combined.
create view myViewAllLanguages(LangCode, c1, c2, c3, ...) as
select 'EN', c1, c2, c3, ... from myTable_English
union all
select 'FR', c1, c2, c3, ... from myTable_French
After you have a combined table or a view that simulates a combined table, then you can easily refer to a query band value in a WHERE clause.
select * from myViewAllLanguages where LangCode = GetQueryBandValue(0, 'Language')

You must sign in to leave a comment.