List:General Discussion« Previous MessageNext Message »
From:Randall Price Date:February 28 2006 9:17pm
Subject:How to pass a string expression into a stored procedure
View as plain text  
I have a SELECT query that looks similar to the following:

 

SELECT

            FirstName,

            LastName

FROM

            myTable

WHERE

            LastName IN ('PRICE', 'SMITH');

 

What I want to do is create a stored procedure for this SELECT query
similar to the following:

 

CREATE PROCEDURE spGetNames (IN strNames VARCHAR(255))

BEGIN

            SELECT

                        FirstName,

                        LastName

            FROM

                        myTable

            WHERE

                        LastName IN (strNames);

END

 

And then I would like to call it like so:

 

CALL spGetNames ('PRICE,SMITH');

 

This does not work, neither does:

 

CALL spGetNames (" 'PRICE', 'SMITH' ");

 

My question is how to format the string parameter so this query works.

 

Any help is greatly appreciated.

 

Thanks,

 

Randall Price

VT.SETI.IAD.MIG : Microsoft Implementation Group

"  http://vtmig.w2k.vt.edu <http://vtmig.w2k.vt.edu/> 

*  Randall.Price@stripped

'  (540) 231-4396

 


Thread
How to pass a string expression into a stored procedureRandall Price28 Feb