Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: DBI Question

by cadfael (Friar)
on Jan 17, 2001 at 20:59 UTC ( [id://52543]=note: print w/replies, xml ) Need Help??


in reply to DBI Question

I am trying to find out if a SQL wildcard ('%') can be used in a DBI script next to a placeholder. Something like this: $sth = $dbh->prepare( "SELECT name FROM people WHERE name LIKE ?%" ); I do this on a regular basis without needing to escape the '%' character, but in Sybase (and I assume MS SQL Server) , a string with a wildcard needs to be quoted:

$sth = $dbh->prepare( "SELECT name FROM people WHERE name LIKE 'Jones%'" );

-----
"Computeri non cogitant, ergo non sunt"

Replies are listed 'Best First'.
Re: Re: DBI Question
by dsb (Chaplain) on Jan 18, 2001 at 19:45 UTC
    Yes. Now how do i do it with a place holder and scalar variable.
    $sth = $dbh->prepare( "SELECT name FROM people WHERE name like ?" ); $sth->execute( $name );
    how do include a wildcard in the where the placeholder is without appending it to the variable.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://52543]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found