in reply to DBD::Pg - function declaration and using alias $n

Slightly off-topic and a shameless (?) plug, but once you have managed to create your stored procedure, please have a look at DBIx::ProcedureCall, which creates Perl wrappers for stored procedures, eliminating the need for writing SQL by hand.

I just added PostgreSQL support yesterday, and am looking for testers. With it you could call your function like so

use DBIx::ProcedureCall qw( poo ); my $result = poo ($dbh, 12345);

As for your problem, I can only offer a work-around: Create the function with the psql command line tool (not with Perl/DBI). You only have to do this once (when installing your program), right?

Replies are listed 'Best First'.
Re^2: DBD::Pg - function declaration and using alias $n
by diotalevi (Canon) on Feb 15, 2005 at 21:01 UTC

    Those functions might be nicer if they live in their own application specific namespace. Consider this.

    $dbh->My::App::poo( 12345 ); package My::App; use DBIx::ProcedureCall qw( poo );
      Those functions might be nicer if they live in their own application specific namespace.

      The code you gave above should work, actually. Thanks for pointing out the interesting syntax.

      $dbh->My::App::poo( 12345 );
      I had no idea this works (calling an object with a fully qualified "method" name). I am going to mention this pattern in the module's docs.
        They'll allow you to use perl's ISA relationships to drive which function is actually called. If that is useful to you.