Variables in TD?

Database
Enthusiast

Variables in TD?

Hi,

I am a TD newcomer and still figuring out details. 

I came across below piece of code that caught my attention.

REPLACE PROCEDURE ABC (IN dbname VARCHAR(30),IN spname VARCHAR(100), IN batchDt DATE ) 
BEGIN

DECLARE tProcDb VARCHAR(30) ;
DECLARE tProcNm VARCHAR(100);
DECLARE tmsg_id, hc1count INTEGER ;
DECLARE sqlmsg VARCHAR(1000);
DECLARE hHex CHAR(2);
DECLARE hAscii, hrepl CHAR(1);

SET tProcDb = dbname;
SET tProcNm = spname;

Are these tProcDb, tProcNm variables? Is this a way to declare and use variables? 

I tried to do this in a separate window.

DECLARE url VARCHAR(1000);
DECLARE id VARCHAR(100);

SET url = 'http://www.ABC.com/CDE/00004537173DA4D4'
SET id = SUBSTRING (url, 5,20))
SELECT id

I got message: The query is invalid.

What am I missing in this picture?

Tags (2)
2 REPLIES
Teradata Employee

Re: Variables in TD?

You can define and use variables inside a stored procedure definition. You can't do that inline in regular Teradata SQL.

Enthusiast

Re: Variables in TD?

Thank you Fred.