Re: Datestyle and Postmaster - Mailing list pgsql-general

From Marc SCHAEFER
Subject Re: Datestyle and Postmaster
Date
Msg-id Pine.LNX.3.96.1001116200523.1018A-100000@defian.alphanet.ch
Whole thread Raw
In response to Datestyle and Postmaster  (Jason Everett <jeverett@esu10.org>)
List pgsql-general
On Thu, 16 Nov 2000, Jason Everett wrote:

> work using psql but I'm not quite sure how to get my programs to do the
> same (other than rewrite them to use the ISO, US style).  Is there a way

I use this in my open_database() Perl function:

# NAME
#    open_database
# DESCRIPTION
#    Opens a database and sets up a reasonable set of defaults.
# RESULT
#    The database handle, or undef.
# NOTES
# BUGS
# TODO
sub open_database {
   # NOTES
   #    - We set AutoCommit to 1 (no transactions for now)
   #      and RaiseError to 0, since we check explicitely all
   #      results.
   my $dbh = DBI->connect("dbi:Pg"
                          . ":dbname=$the_database"
                          . ";host=$the_server",
                          $the_user,
                          $the_password,
                          { RaiseError => 0,
                            AutoCommit => 1
                          });

   if (defined($dbh)) {
      # Also sets up reasonable defaults.

      my $result = 0;
      my $sth = $dbh->prepare("SET DATESTYLE=\'ISO\'");
      if (defined($sth)) {
         my $rv = $sth->execute;

         if (defined($rv)) {
            $result = 1;
            undef $rv;
         }

         $sth->finish;
         undef $sth;
      }

      if ($result == 0) {
         undef $dbh;
      }
   }

   return $dbh;
}



pgsql-general by date:

Previous
From: Matthew
Date:
Subject: RE: [HACKERS] Re: PHPBuilder article -- Postgres vs My SQL
Next
From: Michael Fork
Date:
Subject: Starting Postmaster with -d2