How to get the output of a query run on database

217 views Asked by At

When we execute the query, we can see the error messages with the help of

print OUT "$DBI::errstr";

But how can we get the result of the query on successful execution, like

table TRN_STLMNT_ created
1

There are 1 answers

0
djtsheps On

Having written a few scripts using DBD::mysql and DBD::Sybase database drivers with the DBI module, I found that the best way to figure out if your execution was successful is to enable the raising of errors on you DBI database handle and if no error was raised then you would then manually print out your "table TRN_ST created" message.

my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
                     "joe", "joe's password",
                     {'RaiseError' => 1 });

http://search.cpan.org/~capttofu/DBD-mysql-3.0008/lib/DBD/mysql.pm http://search.cpan.org/~mewp/DBD-Sybase-1.15/Sybase.pm