Teradata variable/view/macro

General
Enthusiast

Teradata variable/view/macro

I am new to Teradata and below is my requirement, not sure how to handle this.
I have two table
Table1

col1 col2
123 data1
456 data1
789 data1

Table2

col3 col4
WHERE col1 = '123' temp

Can I create a dynamic view where the statement is
Select * from Table1
Select col3 from Table2 where col4=user (the value of this should be sent to the above statement.);

The statement to be executed is
Select * from Table1
WHERE col1 = '123' ;
4 REPLIES
Senior Apprentice

Re: Teradata variable/view/macro

You mean the Where-condition "WHERE col1 = '123'" is stored as a string in col3?
This needs Dynamic SQL which is only possible within a Stored Procedure.

How does col4 actually look like?
Is it always a "WHERE col1 = ..."?
Then you could easily rewrite it as a join.

Dieter
Enthusiast

Re: Teradata variable/view/macro

Yes, Where-condition "WHERE col1 = '123'" is stored as a string in col3.
Enthusiast

Re: Teradata variable/view/macro

Please point me to a sample SP similar to this.
WAQ
Enthusiast

Re: Teradata variable/view/macro

check for "DBC.SYSEXECSQL" for more on how dynamic SQL works.