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: sql problem with LIKE

Re: sql problem with LIKE

From: Naresh <nramamur_at_worldnet.att.net>
Date: 1997/09/16
Message-ID: <5vmrtg$782@bgtnsc02.worldnet.att.net>#1/1

Peter,

I'm assuming you are doing this from SQL*Plus. ( Note the ":" before the variables X and Y )

VARIABLE x VARCHAR2(20);
VARIABLE Y VARCHAR2(20);
BEGIN
:X := '19970121%';
select your_field into :Y from your_table where your_field like :X; END;
/

PRINT Y; This should print the value of the field.

Now if you were doing this inside of PL/SQL, you do not need the ":" in front of your variables X and Y.

Hope that solves your problem.

Naresh.

Peter Marusek wrote:
>
> I am having a problem using LIKE with SELECT. In particular, I am
> trying to do a select in my sql script...
> select .... LIKE x;
> where x is a varchar2 variable whose contents are 19970121%
> if I replace the variable x with the quoted string '19970121%' it works
> fine, but the string variable x is evidentally "not equivalent" to
> the quoted string????
> Don't know why the variable method doesn't work...
> Any advice?
> Thanx
  Received on Tue Sep 16 1997 - 00:00:00 CDT

Original text of this message

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