Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: How to change the date in a postgres database via JDBC


  • From: Devrim GÜNDÜZ <devrim(at)gunduz(dot)org>
  • To: niromon <morin(dot)arnaud(at)gmail(dot)com>
  • Cc: pgsql-jdbc(at)postgresql(dot)org
  • Subject: Re: How to change the date in a postgres database via JDBC
  • Date: Wed, 24 Feb 2010 21:58:24 +0200
  • Message-id: <1267041504.2019.715.camel@hp-laptop2.gunduz.org> <text/plain>

On Wed, 2010-02-24 at 09:00 -0800, niromon wrote:

> I need to build a JUnit test that involes to change the date of the
> database during the test.
> I know how to do that with Oracle :
> ALTER SYSTEM SET fixed_date = '2003-01-01-10:00:00';

(If I understood your question correctly: )

If you use now() *in a transaction*, time won't change:

test=# BEGIN ;
BEGIN
test=# SELECT now();
              now              
-------------------------------
 2010-02-24 19:15:02.212511+02
(1 row)

test=# SELECT pg_sleep(5);
 pg_sleep 
----------
 
(1 row)

test=# SELECT now();
              now              
-------------------------------
 2010-02-24 19:15:02.212511+02
(1 row)

test=# 

I don't know any other way to use a fixed date.

-- 
Devrim GÜNDÜZ, RHCE
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org  Twitter: http://twitter.com/devrimgunduz

Attachment: signature.asc
Description: This is a digitally signed message part



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group