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
|