XXP
XXP

Reputation: 23

Teradata SQL parameter syntax

Is there syntax which allows a parameter marker in the middle of a table name? For example, consider the queries

    sel * from t?x

and

    sel * from t?x_blah.

Both execute as

    sel * from t1

if the user inputs 1. In the first query x = 1 and in the second query x_blah = 1. I would like to modify the second query to set x = 1 and execute as

    sel * from t1_blah.

Is there a way to do this?

Thanks!

Upvotes: 1

Views: 3407

Answers (3)

Peter
Peter

Reputation: 1

A ? works in Teradata SQL Assistant. It will ask you to enter the parameter:

select ?x from ?y;

When you run it, SQL Assistant will ask you for the parameters x and y. If you put 10 instances of ?x in your code, SQL Assistant will only ask for x once.

Upvotes: 0

dnoeth
dnoeth

Reputation: 60462

What's your client tool?

SQL Assistant supports parameters for object names, but there's no way to get the expected behavior (as you probably noticed).

The only solution might be using Dynamic SQL within a Stored Procedure.

Upvotes: 1

Andrew
Andrew

Reputation: 8703

A question mark parameter marker can only be used for data values, not object names. So, the short answer is no.

Here's some info from Teradata:Clicky!

Upvotes: 1

Related Questions