DBIx::Roles::StoredProcedures - Treats any method reached AUTOLOAD as a call to a


DBIx-Roles documentation Contained in the DBIx-Roles distribution.

Index


Code Index:

NAME

Top

DBIx::Roles::StoredProcedures - Treats any method reached AUTOLOAD as a call to a stored procedure.

DESCRIPTION

Top

Useful when database contains many stored procedures.

SYNOPSIS

Top

     use DBIx::Roles qw(StoredProcedures);

     my $dbh = DBI-> connect(
           "dbi:Pg:dbname=template1",
	   "postgres",
	   "password",
     );

     print $dbh-> pg_backend_pid(), "\n";

SEE ALSO

Top

DBIx::Roles.

COPYRIGHT

Top

AUTHOR

Top

Dmitry Karasik <dk@catpipe.net>


DBIx-Roles documentation Contained in the DBIx-Roles distribution.

# $Id: StoredProcedures.pm,v 1.1.1.1 2005/11/20 18:01:06 dk Exp $

package DBIx::Roles::StoredProcedures;

use strict;
use vars qw($VERSION);

$VERSION = '1.00';

sub initialize
{
	return undef, undef, qw(call_function);
}

sub call_function
{
	my ( $self, $storage, $function, @params) = @_;
	
	return $self-> selectrow_array(
		"SELECT $function (".
			join(',', map { '?' } @params) .
		")", 
		{},
		@params
	);
}

# XXX any() is greedy here, but checking whether there is a corresponding stored procedure
# takes intimate knowledge about the particular DBD driver, so we leave that for now
sub any
{
	my ( $self, $storage, $method, @params) = @_;

	return call_function( $self, $storage, $method, @params);
}

1;

__DATA__