Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to declare and use a variable

Status
Not open for further replies.

bkj123

Technical User
Aug 23, 2002
43
US
Hello -
2 questions please:
(1) How do I declare and use a variable? In the code below, I'm looking to declare a variable and use it in a WHERE statement..

DECLARE vsor_id CHAR(7);
SET vsor_id = 'V','I';

SELECT
count(*)
FROM
bkj_churn_def
WHERE
sor_id in :)vsor_id);

/* The actual code is*/
SELECT
count(*)
FROM
bkj_churn_def
WHERE
sor_id in ('V','I');

However, I'm getting a syntax error: 3706: syntax error: expected something between the beginning of the request and the 'DECLARE' keyword.

How can I resolve?

(2) What terdata reference books would you recommend besides "Teradata SQL Unleash the Power" by Larkins & Coffing?

Thank you.
 
am assuming that u r trying to submit a stored procedure.
u cannot perform SELECT in sp. u need to have SELECT INTO.



Try referencing manual provided by Teradata.
These manual are also available on
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top