Re: Datestyle and Postmaster

From: Marc SCHAEFER <schaefer(at)alphanet(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Datestyle and Postmaster
Date: 2000-11-16 19:08:27
Message-ID: Pine.LNX.3.96.1001116200523.1018A-100000@defian.alphanet.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;
}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Max Fonin 2000-11-16 19:24:20 Enum type emulation: problem with opaque type in PL/pgSQL functions
Previous Message Jason Everett 2000-11-16 18:47:23 Datestyle and Postmaster