++ed by:
Author image Joel Jacobson
and 1 contributors


DBIx::Pg::CallFunction - Simple interface for calling PostgreSQL functions from Perl


version 0.003


    use DBI;
    use DBIx::Pg::CallFunction;

    my $dbh = DBI->connect("dbi:Pg:dbname=joel", 'joel', '');
    my $pg = DBIx::Pg::CallFunction->new($dbh);

Returning single-row single-column values:

    my $userid = $pg->get_userid_by_username({'username' => 'joel'});
    # returns scalar 123

Returning multi-row single-column values:

    my $hosts = $pg->get_user_hosts({userid => 123});
    # returns array ref ['', '', ...]

Returning single-row multi-column values:

    my $user_details = $pg->get_user_details({userid => 123});
    # returns hash ref { firstname=>..., lastname=>... }

Returning multi-row multi-column values:

    my $user_friends = $pg->get_user_friends({userid => 123});
    # returns array ref of hash refs [{ userid=>..., firstname=>..., lastname=>...}, ...]


This module provides a simple efficient way to call PostgreSQL functions with from Perl code. It only support functions with named arguments, or functions with no arguments at all. This limitation reduces the mapping complexity, as multiple functions in PostgreSQL can share the same name, but with different input argument types.


Limitations and Caveats

Requires PostgreSQL 9.0 or later.

Joel Jacobson http://www.joelonsql.com

Copyright (c) Joel Jacobson, Sweden, 2012. All rights reserved. You may use and distribute on the same terms as Perl 5.10.1.

# vim: ts=8:sw=4:sts=4:et