Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Wed, 21 Dec 2005 @ 13:07:34 GMT

  <Prev Next>  
Next> Last>>  

Subj:   Passing the value for an IN clause to a stored
From:   Watson, Matt

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)
     select count(branch_id)
     into :valout
     from branch
     where mail_state in ( :varlist );

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);

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

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.



  <Prev Next>  
Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 28 Jun 2020