Results 1 to 5 of 5
  1. #1
    Join Date
    May 2010
    Posts
    3

    Unanswered: Parameter in a Like Predicate

    Hello everybody,

    I want to ask you for help. I'm trying to create a procedure with a input parameter for instance "var1". And in the procedure I'm using LIKE predicate, where I want to put the parameter in the pattern side.
    Something like this:

    ..... WHERE r.name LIKE '%var1%' .........

    but it takes var1 like a char, not like a parameter, so if you have some advices I'll be glad

    Thank you all.

  2. #2
    Join Date
    Jun 2007
    Location
    germany
    Posts
    155
    never concatonated a like predict
    LIKE '%'||var1||'%'

    but most times, I build the % within var1
    Last edited by dbzTHEdinosaur; 05-20-10 at 04:15.
    Dick Brenholtz, Ami in Deutschland

  3. #3
    Join Date
    Jul 2009
    Posts
    150

    Arrow Like ==> locate

    Quote Originally Posted by dbzTHEdinosaur View Post
    never concatonated a like predict
    LIKE '%'||var1||'%'

    but most times, I build the % within var1
    Instead of LIKE you can use LOCATE function. With the same result.

    Kara

  4. #4
    Join Date
    May 2010
    Posts
    3

    Index Structure. Has table

    Thank you all

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by ProXtremer View Post
    Hello everybody,

    I want to ask you for help. I'm trying to create a procedure with a input parameter for instance "var1". And in the procedure I'm using LIKE predicate, where I want to put the parameter in the pattern side.
    Something like this:

    ..... WHERE r.name LIKE '%var1%' .........

    but it takes var1 like a char, not like a parameter, so if you have some advices I'll be glad

    Thank you all.
    You can use dynamic SQL to create the SQL statement, the prepare and execute it (or execute immediate).
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •