chauzer has asked for the wisdom of the Perl Monks concerning the following question:
when there's an error in a query, like say its trying to update a field in the table and the type isn't correct, it'll print out my error message.. however, i have a trigger on a table, and in that trigger, if it found something, i.e. field1 != field2, then it will raise an error in SQL server, but it looks like DBI doesn't catch that error here's the code inside the trigger:if($dbh = DBI->connect($connectionInfo,$userid,$passwd)){ $sth = $dbh->prepare($query); if($sth->execute()){ @dsetcols=[]; $xi=0; @fieldnames = split(/,/, $fnames); foreach $fieldname (@fieldnames) { $ds{$dsetname}{$fieldname}=[]; push @dsetcols,""; $sth->bind_col($xi+1,\$dsetcols[$xi]); if ($fieldname eq "task_id") { } $xi++; } while($sth->fetch()) { $xi=0; foreach $fieldname (@fieldnames) { push @{$ds{$dsetname}{$fieldname}},safedecode($dsetcol +s[$xi]); $xi++; } } $sth->finish(); }else{ print "Query \""; print $query; print "\" failed.<br>"; print "Database error message: "; print $dbh->errstr; print "<p>"; # used in do_autorefresh, detail window won't automatica +lly close if query failed $badquery = 1; } $dbh->disconnect; }else{print "Could not connect to database.<br>";} } $x++; }
any idea on why this isn't working? ive been doing some testing.. and DBI will report the SQL error given by the trigger if i'm doing an INSERT statement into a table and that table has a trigger on inserts and updates.. however if i do a UPDATe statement on that table, DBI would report the SQL error given by the trigger thanks!IF (@max_vendor != (SELECT vendor_id FROM Inserted)) BEGIN RAISERROR ('PO already exists with a different vendor',16,1) ROLLBACK TRAN END
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl w/ DBI connectiong to MSSQL, not reporting SQL server trigger errors
by runrig (Abbot) on Jan 06, 2005 at 19:01 UTC | |
by legato (Monk) on Jan 06, 2005 at 19:07 UTC | |
by runrig (Abbot) on Jan 06, 2005 at 19:14 UTC | |
by chauzer (Novice) on Jan 06, 2005 at 20:28 UTC | |
by runrig (Abbot) on Jan 06, 2005 at 21:02 UTC |