On Thu, Nov 14, 2002 at 09:36:21AM -0500, David N Murray wrote:
> Hmmm, I don't know if I agree with the %$date is a reference sentiment:
> 
> $ cat t.pl
> $d = "7-Aug";
> print "%$d%";
> print "\n";
> $ perl t.pl
> %7-Aug%
> $

That is correct, Perl interpolates scalars and arrays in double-quoted
strings, but not hashes.


> SQL> select * from t1;
> 
> D
> ---------
> 07-AUG-02
> 
> SQL> select * from t1 where d like '%7-Aug%';
> 
> no rows selected

'07-AUG-02' is not like '%7-Aug%' because the case doesn't match.


Ronald


> 
> SQL>
> 
> Jim, is your column date or another type? My test was on Oracle 8.1.7 for
> RH Linux.  Changing the datatype to varchar2 works for me, but makes
> comparisons for dates impossible (e.g. select * from t where d >
> '7-Aug-2002';).
> 
> Dave
> 
> On Nov 14, Hapworth, Adam scribed:
> 
> >
> >
> >
> > > I have a simple query using a LIKE in the statement and I just can get it
> > > to
> > > return any data. I know it works because i can do it in sqlplus and get
> > > data
> > > returned. I have tried everything to try to quote it correctly, like qq,
> > > qw,
> > > dbh->quote and finally placeholders. Code is below, any ideas ?
> > >
> > > Thanks
> > > Jim
> > > ------
> > >
> > > # my $string = $dbh->quote("%7-Aug%");
> > > my $date = qq(7-Aug);
> > >
> > > my $sth = $dbh->prepare("SELECT * FROM uptime WHERE sdate LIKE ?" )
> > >     or die "can't prepare: $DBI::errstr\n";
> > >
> > > $sth->execute("%$date%") or die "can't execute $DBI::errstr\n";
> > > my @row;
> > > while (@row = $sth->fetchrow_array() ) {
> > >         print "@row\n";
> > > }
> > >
> >
> > You may want to use concationation on this or escape the %
> >                 ("%".$date."%")
> >     $sth->execute("%$date%") or die "can't execute $DBI::errstr\n";
> > the double quotes will allow for the %$date to be read a has reference
> > instead of a "%"$date"%" like you are trying to do.
> >
> 
> 

Reply via email to