Manual Reference Pages - ITERATOR::DBI (3)
Iterator::DBI - An iterator for returning DBI query results.
This documentation describes version 0.02 of Iterator::DBI, August 23, 2005.
# 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
This is marginally more useful than simply calling
prepare and execute, and then repeatedly
calling fetchrow_hashref; since this one
function bundles up the calls to all three of those DBI methods.
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
$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 @bind.
$dbh = DBI->connect (...);
$iter = idb_rows ($dbh, select foo, bar from quux);
$row_ref = $iter->value;
The following symbol is exported to the callers namespace:
Iterator::DBI uses Exception::Class objects for throwing exceptions.
If youre not familiar with Exception::Class, dont worry; these
exception objects work just like $@ does with die and 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"
The DBI prepare method returned an error.
String: "idb_rows cannot execute sql: message"
The DBI execute method returned an error.
String: "idb_rows: fetch error: message"
The DBI 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.
AUTHOR / COPYRIGHT
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
modules name in the messages subject line, and/or GPG-sign your
|perl v5.20.3 ||DBI (3) ||2005-08-23 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.