Home > Archive > MySQL ODBC Connector > February 2006 > How to pass a string expression into a stored procedure









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to pass a string expression into a stored procedure
Price, Randall

2006-02-28, 8:28 pm

------ _=_NextPart_001_01C6
3CAC.552B997F
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I have a SELECT query that looks similar to the following:

=20

SELECT

FirstName,

LastName

FROM

myTable

WHERE

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

=20

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

=20

CREATE PROCEDURE spGetNames (IN strNames VARCHAR(255))

BEGIN

SELECT

FirstName,

LastName

FROM

myTable

WHERE

LastName IN (strNames);

END

=20

And then I would like to call it like so:

=20

CALL spGetNames ('PRICE,SMITH');

=20

This does not work, neither does:

=20

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

=20

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

=20

Any help is greatly appreciated.

=20

Thanks,

=20

Randall Price

VT.SETI.IAD.MIG : Microsoft Implementation Group

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

* Randall.Price@vt.edu

' (540) 231-4396

=20


------ _=_NextPart_001_01C6
3CAC.552B997F--
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com