Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Parameter in Stored Procedure with like xxx%
Thu, Feb 28 2008 10:40 AMPermanent Link

Uli Becker
Hi,

I juse this code for a stored procedure:

BEGIN
DECLARE Result CURSOR WITH RETURN FOR Stmt;

  BEGIN
  PREPARE Stmt FROM 'SELECT * from Patienten where
                     Name = ? and Vorname = ?';
  OPEN Result using Name, Vorname;
  END;
END

Works fine. How can I use the like-operator together with the parameters in a Stored
Procedure, something like this:

  PREPARE Stmt FROM 'SELECT * from Patienten where
                     Name like ?% and Vorname like ?%';


Regards Uli

Fri, Feb 29 2008 8:40 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< Works fine. How can I use the like-operator together with the parameters
in a Stored Procedure, something like this: >>

Use this:

BEGIN
DECLARE Result CURSOR WITH RETURN FOR Stmt;

  BEGIN
  PREPARE Stmt FROM 'SELECT * from Patienten where
                     Name = ? and Vorname = ?';
  OPEN Result using Name+'%', Vorname+'%';
  END;
END

--
Tim Young
Elevate Software
www.elevatesoft.com

Fri, Feb 29 2008 8:49 AMPermanent Link

Uli Becker
<<
OPEN Result using Name+'%', Vorname+'%';
>>

This is tricky SmileThanks a lot.

Regards Uli

Fri, Feb 29 2008 9:41 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< This is tricky SmileThanks a lot. >>

Well, you could have embedded the % characters in the actual SQL text also,
but it would have been a lot less readable.

--
Tim Young
Elevate Software
www.elevatesoft.com

Fri, Feb 29 2008 9:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli

>This is tricky SmileThanks a lot.

Dead right - I've applied for a brain upgrade Smiley

Roy Lambert
Image