Iterator::DBI - An iterator for returning DBI query results.
This documentation describes version 0.02 of Iterator::DBI, August 23, 2005.
use Iterator::DBI; # Iterate over a database SELECT query. # (returns one hash reference per row). $iter = idb_rows ($dbh, $sql); $iter = idb_rows ($dbh, $sql, @bind);
This module contains a function to return an iterator (see the Iterator module) that returns the rows of a database query, one at a time.
But the real usefulness of this interface is that it can be chained together with other Iterator functions. The "idb_rows" iterator has the same interface as any other interface, making it interchangeable with iterators of any other source (for example, files), and usable with the iterator manipulation functions in the Iterator::Util module.
$it = idb_rows ($dbh, $sql); $it = idb_rows ($dbh, $sql, @bind);
Returns an iterator to return rows from a database query. Each row is returned as a hashref, as from
fetchrow_hashref|DBI/fetchrow_hashref from the DBI module.
If the query requires bind variables, they may be passed in
$dbh = DBI->connect (...); $iter = idb_rows ($dbh, 'select foo, bar from quux'); $row_ref = $iter->value;
The following symbol is exported to the caller's namespace:
Iterator::DBI uses Exception::Class objects for throwing exceptions. If you're not familiar with Exception::Class, don't worry; these exception objects work just like
$@ does with
croak, but they are easier to work with if you are trapping errors.
You can learn more about Iterator exceptions in the Iterator module documentation.
You called idb_rows with one or more bad parameters. Since this is almost certainly a coding error, there is probably not much use in handling this sort of exception.
As a string, this exception provides a human-readable message about what the problem was.
String: "idb_rows cannot prepare sql: message"
prepare method returned an error.
String: "idb_rows cannot execute sql: message"
execute method returned an error.
String: "idb_rows: fetch error: message"
fetchrow_hashref method returned an error.
Requires the following additional modules:
Higher Order Perl, Mark Jason Dominus, Morgan Kauffman 2005.
The Iterator module.
The DBI module.
Eric J. Roode, email@example.com
Copyright (c) 2005 by Eric J. Roode. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To avoid my spam filter, please include "Perl", "module", or this module's name in the message's subject line, and/or GPG-sign your message.