INSERT INTO table_name [(column_list)] VALUES (value1, value2, ...)
Unlike ordinary usage of quotation marks in Perl, the values in an insert statement must be single quoted, even if they are scalar variables. This causes them to be interpolated properly. Without them, an "Invalid Bracketing" error occurs.
INSERT INTO title (name, title_id, edition, price) VALUES ('Romeo and Juliet', 3725, 11, 12.50)
INSERT INTO title VALUES (3725, 'Romeo and Juliet', 12.50, 11)
$sth = $dbh->prepare(qq{ INSERT INTO title (name, price, edition) VALUES ('$name', '$price', '$edition')})
When the values come from Perl variables, must they be quoted?
Which kind of quotation marks should be used when passing an INSERT statement to the ->prepare method?
|
Dan Keller Technical Services 4500 19th St., San Francisco California, USA 94114 tel: 415 / 861-4500 |