Teradata Studios Create Local Variable

Database

Teradata Studios Create Local Variable

I have a query that I would like to avoid hard coding. Using the following example could you give me the code to create such a variable:

select region
from geography_table
where division = 'Central'

I know in MS SQL Server (T-SQL) you can say "declare @division VARCHAR(20)" and set @division = 'Central' before the query will create the variable, but that doesn't work in Teradata.

Thanks for the help.

Tags (2)
2 REPLIES
N/A

Re: Teradata Studios Create Local Variable

were you able to figure this out? looking to do the same thing

Re: Teradata Studios Create Local Variable

Hi Darres,

Can you try like this. I haven't ran this but giving you the sample code snippet.

REPLACE Sample_Proc

(

  REGION VARCHAR(20)

)

BEGIN

DECLARE vDivision VARCHAR(20);

/*OPERATION1*/

SET vDivision= 'Central'

/*OPERATION 2*/

select region

from geography_table

where division = vDivision

/*CALLING THE PROCEDURE*/

CALL Sample_Proc('ABCD');