The main problem is with your SQL_EXE code. 1) You're working too hard to trap errors. 2) You are executing the query in that routine and you probably shouldn't be. Something like this would work better for you:
Code:
my $sql_syntax = qq~INSERT INTO $table_inquiry
(comment1, comment2, comment3) VALUES (?, ?, ?)~;
my $sth = $dbh->prepare($sql_syntax) or die $dbh->errstr;
$sth->execute($comment1, $comment2, $comment3) or die $sth->errstr;
And even better would be:
Code:
# Use something like this to connect
my $dbh = DBI->connect($data_source, $user, $pass, {
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
});
# Rest of your code...
# Your insert code
my $query = qq~INSERT INTO $table_inquiry
(comment1, comment2, comment3) VALUES (?, ?, ?)~;
$dbh->do($query, undef, $comment1, $comment2, $comment3);
As I mentioned in the above post you can set the
RaiseError attribute to true so DBI will automagically die on all errors and you don't have to test every single method return. Read over the POD on
connect and
do for additional info.
Next: On your execute:
Code:
$sth->execute(comment1, comment2, comment3);
You need to use
$comment1 or
'comment1' for all of your values. You can't use bare words like you have now.
Hopefully that will get you going.
~Charlie