Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: '%' in variable used in like clause (PL/SQL)

Re: '%' in variable used in like clause (PL/SQL)

From: Vrajesh Patel <vrajesh.patel_at_mci.com>
Date: Thu, 22 Apr 1999 15:37:00 GMT
Message-ID: <371F4211.AC8B0403@mci.com>


You query should definitely work. As, I tried the same from me as follows.

set serverout on

declare
 val char(10);
 res integer;
begin
 val:='%';
 select count(*) into res from temp where name like '%';  dbms_output.put_line(res);
end;
/

and table has five records and displayed all.

Thanks,

Vrajesh.

Remi Delon wrote:

> Hi, I'm trying to use variables to build a WHERE clause with a LIKE operator.
>
> My problem is that puting the '%' sign in the variable doesn't seem to be
> working. For example, if I try something like :
> declare
> val char(10);
> res integer;
> begin
> val:='%';
> select count(*) into res from my_table where col like val;
> end;
>
> No rows are selected, even though my_table contains lots of datas !
> I've noticed that if, let's say, 'col' is a 4-digit integer and I use
> val:='____' instead of val:='%', it's working and all rows are selected !!
>
> Any ideas on what's going on ?
>
> Thanks
>
> Remi.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Received on Thu Apr 22 1999 - 10:37:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US