DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: SQL LIKE and variables

  1. #1
    Join Date
    Feb 2001
    Posts
    6

    Unhappy

    Is it possible do use a variable instead of a hard-coded value to do a LIKE in PL/SQL? For example, something like

    i_string char(10) := '%ABC%'
    SELECT count(*) INTO i_cnt FROM table WHERE column LIKE i_string;

    That particular syntax doesn't work, and neither do any of the other ways I've tried. I know I can do it with NDS, but I'd rather not unless I have to.

    Thanks,

    Vince

  2. #2
    Join Date
    May 2000
    Posts
    58
    Either modify i_string char(10) := '%ABC%'
    to i_string varchar2(10) := '%ABC%'
    or
    modify the select to
    SELECT count(*) INTO i_cnt FROM table WHERE column LIKE rtrim(i_string);

    If you use char, the value in i_string is actually '%ABC '
    (10 characters !!!!! )



Posting Permissions

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


Click Here to Expand Forum to Full Width