DBIx::Pg::CallFunction - Simple interface for calling PostgreSQL functions from Perl
version 0.002
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 ['127.0.0.1', '192.168.0.1', ...]
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.
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
To install DBIx::Pg::CallFunction, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Pg::CallFunction
CPAN shell
perl -MCPAN -e shell install DBIx::Pg::CallFunction
For more information on module installation, please visit the detailed CPAN module installation guide.