Has anyone here done any work with PostgreSQL stored procedures which
themselves use DBI?  Essentially, I've got a stored procedure that looks
like ...

CREATE FUNCTION fn_stored_proc(integer) as '
  use DBI;
  my $dbh = DBI->connect(...);
  my $sth = $dbh->prepare(...);
  $sth->execute(...);
  return $sth->fetch...;
' LANGUAGE 'plperlu';

Of course, there's more to it than this: it calls some other local
procedures to construct values that can't be easily constructed in SQL.

My problem is that for such procedures, doing:

  select fn_stored_proc(id_field) from table_name;

opens and closes the database connection over and over.  This is very
inefficient.  Is there some way to "inherit" the connection so it
doesn't have to be recreated?

-- 
Jeff Boes                                      vox 616.226.9550 ext 24
Database Engineer                                     fax 616.349.9076
Nexcerpt, Inc.                                 http://www.nexcerpt.com
           ...Nexcerpt... Extend your Expertise

Reply via email to