Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Escaping single quotes and DBI

by ezekiel (Pilgrim)
on Sep 06, 2001 at 11:37 UTC ( [id://110516]=note: print w/replies, xml ) Need Help??


in reply to Escaping single quotes and DBI

Thanks for the pointers, I solved the problem by familiarizing myself with the quote method.

However, I'd like to explore the placeholder stuff. On seeing the responses I asked myself the same question: why am I not using placeholders? To explain I have to expand the example slightly. Imagine it reads:

# $comment is a text comment, $id is a integer my $sql = "insert into my_table ". "(ID, COMMENT) " . "values (?, ?)"; my $sth = $dbh->prepare($sql); my $rc = $sth->execute($id, $comment);

This works fine with MySQL as the database, but I am also using the same code with DB2. It seems DBI quotes the $id integer. DB2 therefore thinks it is a string and refuses to insert it because the column takes integers.

I'll keep working my way through the DBI docs, but does anyone know why this should be the case? or a way around it?

Thanks again

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found