Loading ...
Sorry, an error occurred while loading the content.

DBI::Pg problems in a mod_perl based SOAP server under Apache

Expand Messages
  • John Michael Zorko
    Hello, all ... I m experiencing weird things ... i ve some simple DBI code that talks to a local PostgreSQL database via DBD::Pg that does a basic query and
    Message 1 of 1 , Jan 24, 2005
    • 0 Attachment
      Hello, all ...

      I'm experiencing weird things ... i've some simple DBI code that talks
      to a local PostgreSQL database via DBD::Pg that does a basic query and
      displays the rows. The weird thing is that the code works in a Perl
      script, but not in a mod_perl based SOAP server under Apache. Is there
      something else I need? This is under Mac OSX 10.3.7.

      This works:

      #!/usr/bin/perl -w

      use strict;
      use DBI;

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

      if ( $dbh )
      {
      my $res = $dbh->selectall_arrayref( "select * from foo" );

      foreach my $row ( @$res )
      {
      print @$row[ 0 ] . "\n";
      }
      }

      ... but this does not (when the client calls doquery(), undef is
      returned, I was expecting either the result set or "Cannot connect to
      database"):

      #!/usr/bin/perl -w

      use SOAP::Transport::HTTP;

      tie *STDOUT, 'Apache';

      SOAP::Transport::HTTP::CGI
      -> dispatch_to('Demo')
      -> handle;

      package Demo;

      use DBI;

      sub doquery
      {
      my $dbh = DBI->connect( "dbi:Pg:dbname=test", "postgres", "postgres"
      );

      if ( $dbh )
      {
      my $res = $dbh->selectall_arrayref( "select * from foo" );

      return $res;
      }
      else
      {
      return "Could not connect to database";
      }
      }

      Does anyone have any ideas as to what the problem could be? Do I need
      something special for SOAP::Lite under Apache to use DBI and DBD::Pg?

      Regards,

      John

      Falling You - exploring the beauty of voice and sound
      New album, "Touch", available now
      http://www.magnatune.com/artists/falling_you
    Your message has been successfully submitted and would be delivered to recipients shortly.