pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to change the date in a postgres database via JDBC
2+ messages / 2 participants
[nested] [flat]

* How to change the date in a postgres database via JDBC
@ 2010-02-24 17:00 niromon <morin.arnaud@gmail.com>
  2010-02-24 19:58 ` Re: How to change the date in a postgres database via JDBC Devrim GÜNDÜZ <devrim@gunduz.org>
  0 siblings, 1 reply; 2+ messages in thread

From: niromon @ 2010-02-24 17:00 UTC (permalink / raw)
  To: pgsql-jdbc


Hi,

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';

But I work with Postgres now and I've found nothing about it on the web.

Someone can help me ?

have a nice day.

Arnaud
-- 
View this message in context: http://old.nabble.com/How-to-change-the-date-in-a-postgres-database-via-JDBC-tp27714250p27714250.htm...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How to change the date in a postgres database via JDBC
  2010-02-24 17:00 How to change the date in a postgres database via JDBC niromon <morin.arnaud@gmail.com>
@ 2010-02-24 19:58 ` Devrim GÜNDÜZ <devrim@gunduz.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Devrim GÜNDÜZ @ 2010-02-24 19:58 UTC (permalink / raw)
  To: niromon <morin.arnaud@gmail.com>; +Cc: pgsql-jdbc

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

Attachments:

  signature.asc (application/pgp-signature, 197B) download

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2010-02-24 19:58 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-02-24 17:00 How to change the date in a postgres database via JDBC niromon <morin.arnaud@gmail.com>
2010-02-24 19:58 ` Devrim GÜNDÜZ <devrim@gunduz.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox