in reply to Return results of UPDATE statement

What do you mean by "results of said UPDATE statement"? Normally the result is either a success or a failure. If you set the PrintError option when connecting to DBI, you get automatically notified of errors. Or you can check $dbh->err<c/> and <c>print "Success\n" if there was no error.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Return results of UPDATE statement
by kdmurphy001 (Sexton) on Oct 12, 2009 at 12:02 UTC
    Sorry for not making that clear. When you run the update statement you get something like the following.

    Query OK, 1 row affected, 1 warning (0.01 sec)

    Thats actually from an INSERT statement but it's very similiar. I'm looking for a way to get that output either to a screen or file. The errstr dosen't have anything in it when I print it.

      This string is generated by the mysql command line client, and since you don't use it, you have to construct it yourself.

      I think you can obtain the number of affected rows as the return value of $dbh->execute (but please check the documentation first), the time difference is easily computed by invoking time before and after the query, use Time::HiRes get sub-second resolution.

      Perl 6 - links to (nearly) everything that is Perl 6.
      You can get the number of rows affected by the previous statement using
      $sth->rows();
      where $sth is the statement handle.