NAME

Eve::PgSqlFunction - a PostgreSQL stored function class.

SYNOPSIS

my $foo = Eve::PgSqlFunction->new(
    connection => $pgsql_connection,
    name => 'foo',
    input_list => [
        {'bar' => $pgsql_bigint}],
    output_list => [
        {'bar' => $pgsql_bigint},
        {'baz' => $pgsql_text}]);

my $result_list = $foo->execute(value_hash => {'bar' => 123});

DESCRIPTION

Eve::PgSqlFunction is an adapter class for PostgreSQL stored function. It adapts DBI DBD::Pg statement handle and encapsulates statement preparation and execution mechanisms.

Attributes

sth

a service attribute containing a statement handle (not for regular use).

Constructor arguments

connection

a PostgreSQL connection (Eve::PgSqlConnection) object

name

a stored function name

input_list

an optional list of input parameters, each of which is specified as a structure like

{'parameter_name' => $parameter_type}

where the $parameter_type is a Eve::PgSqlType derivative.

output_list

an optional list of output parameters specified, just like the input_list argument

is_set_returning

A boolean value depending of what do we expect from the function - a set or one row.

Throws

Eve::Error::Value

when input or output parameter definitions does not match the required definition format.

METHODS

init()

_transform_parameter_list()

execute()

Executes the stored function.

Arguments

value_hash

an optional hash of the input parameters substitutions where keys are parameter names and values are values to substitute.

Returns

A list of hashes corresponding to the rows returning from the stored function if is_set_returning is true or a hash of a single row otherwise.

Throws

Eve::Error::Value

in case when input values does not meet the signature of the stored function, when resulting columns set does not meet required output parameters or when 0 or more than 1 row returned in case of not set returning function.

SEE ALSO

DBI
DBD::Pg
Eve::Exception
Eve::PgSqlConnection
Eve::PgSqlType

LICENSE AND COPYRIGHT

Copyright 2012 Igor Zinovyev.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

AUTHOR

Sergey Konoplev