[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    How to pass a string expression into a stored procedure
From:       "Price, Randall" <randallp () vt ! edu>
Date:       2006-02-28 21:17:07
Message-ID: 4C058118EC56B34E809904A5D0DA30872A70A0 () elessar ! cc ! w2k ! vt ! edu
[Download RAW message or body]


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@vt.edu

'  (540) 231-4396

 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic