Let
DBD::ODBC do the quote escaping, it knows what kind of escapes to use. This can be done with $dbh->quote() as others have said, but it can also be done with placeholders and placeholders have many other benefits. Read the
DBI docs about placeholders, here's an example:
my $sth = $dbh->prepare(q{
INSERT INTO TRANS_TABLE
(Id, TransString, PoundDef, Filename)
VALUES( ?, ? , ?, ?)
});
$sth->execute(
0,
q{Attempt' to connect to %U?},
q{qtn_ics_ap_conne ct_text},
q{agentdialog_00.loc}
);