DBIx::Fun - access database stored procedures as methods
use DBI; use DBIx::Fun; my $dbh = DBI->connect('dbi:Oracle:orcl', 'scott', 'tiger'); my $fun = DBIx::Fun->context($dbh); # print 5 random numbers from the database $fun->dbms_random->initialize( 123 ); for my $i ( 1 .. 5 ) { printf "%d %d\n", $i, $fun->dbms_random->random; } $fun->dbms_random->terminate; $dbh->disconnect;
This module allow Perl programs to access database stored procedures as if they were methods on an object.
Creates a DBI::Fun subclass matching the driver of $dbh, e.g., DBD::Oracle => DBIx::Fun::Oracle.
DBI::Fun
# call as a class method my $fun = DBIx::Fun->context($dbh);
Privately used as an object method to create child contexts.
Returns a context for $dbh, cached in $dbh. Exportable as a function.
use DBIx::Fun 'fun'; print fun($dbh)->sysdate, "\n"; sleep 60; # function signature cached in $dbh print fun($dbh)->sysdate, "\n";
Not an actual function. Importing 'auto' will load fun() into the DBI::db package, exposing it as a method on database handles.
use DBIx::Fun 'auto'; print $dbh->fun->sysdate, "\n";
Accessor for the underlying database handle.
Convenience methods on the underlying database handle.
Call stored proc $name with arguments @args.
$name
$fun->_call() can be used to call a stored procedure that contains characters not allowed in a Perl identifier, or that clashes with a method defined in Perl.
$fun->_call()
To install DBIx::Fun, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Fun
CPAN shell
perl -MCPAN -e shell install DBIx::Fun
For more information on module installation, please visit the detailed CPAN module installation guide.