Name
DBI::dump_results
Synopsis
$neat_rows = DBI::dump_results($statement_handle); $neat_rows = DBI::dump_results($statement_handle, $maxlen); $neat_rows = DBI::dump_results($statement_handle, $maxlen, $line_sep); $neat_rows = DBI::dump_results($statement_handle, $maxlen, $line_sep, $field_sep); $neat_rows = DBI::dump_results($statement_handle, $maxlen, $line_sep, $field_sep, $file_handle);
DBI::dump_results
prints the contents of a
statement handle in a neat and orderly fashion by calling
DBI::neat_string
on each row of data. This is
useful for quickly checking the results of queries while you write
your code. The only required argument is the statement handle to
print out. If a second argument is present, it is used as the maximum
length of each field in the table. The default is 35. A third
argument is the string used to separate each line of data. The
default is \n
. The fourth argument is the string
used to join the fields in a row. The default is a comma. The final
argument is a reference to a filehandle glob. The results are printed
to this filehandle. The default is STDOUT
. If the
statement handle cannot be read, an undefined value undef
is returned.
Example
use DBI; my $db = DBI->connect('DBI:mSQL:mydata',undef,undef); my $query = "SELECT name, date FROM myothertable"; my $myothertable_output = $db->prepare($query); $myothertable_output->execute; print DBI::dump_results($myothertable_output); # Print the output in a neat table. open(MYOTHERTABLE,">>myothertable"); print DBI::dump_results($myothertable_output,undef,undef,undef,\*MYOTHERTABLE); ...
Get MySQL and mSQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.