Passing the value for an IN clause to a stored procedure.
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Passing the value for an IN clause to a... Expand / Collapse
Author
Message
Posted 12/21/2005 11:24:44 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 1/3/2006 10:07:00 AM
Posts: 1, Visits: 1
I'd like to create a stored procedure that can accept a string with multiple values as a parameter, and then put that into an IN clause in the query. Here's an example of what I'm trying to do:

CREATE PROCEDURE dss_tables.mw_test_proc(varlist varchar(200), OUT valout smallint)
BEGIN
select count(branch_id)
into :valout
from branch
where mail_state in ( :varlist );
END;

The idea would be to pass in a list of states ('PA','OH','AL') and get back a total count of branches that are in those states.



The stored proc will build OK, and if you pass in one branch it works fine:

call dss_tables.mw_test_proc( 'PA', valout);
>>36

call dss_tables.mw_test_proc( 'AL', valout);
>>6

But if I try to pass in two or more branches, I always get 0 back. I've tried doubling-up the single quotes several different ways, but with no luck:
call dss_tables.mw_test_proc( 'AL'',''PA', valout);
call dss_tables.mw_test_proc( '''AL'',''PA''', valout);


Any suggestions would be much appreciated.

Thanks,
Post #3229
Posted 1/3/2006 9:23:21 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 8/3/2006 2:56:00 PM
Posts: 13, Visits: 1
Very helpful. Tagging for later.
Post #3287
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 2 ( 2 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 12:06am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.031. 8 queries. Compression Disabled.