Controlling SYSDATE

July 9, 2012 at 10:29 am | Posted in Oracle Developement, PL/SQL | Leave a comment
Tags: , , ,

For certain testing scenarios, I need to have SYSDATE return a certain date. This can be done with Oracle’s FIXED_DATE parameter.

For example, if you want SYSDATE to return ‘05-OCT-2011 15:30:00’ do the following as sys:

alter system set fixed_date = '2011-10-05 15:30:00';

If you want SYSDATE back to normal and return the correct date do:

alter system set fixed_date = none;

Note that this does not influence the behavior of SYSTIMESTAMP.

See also: http://docs.oracle.com/cd/E11882_01/server.112/e25513/initparams092.htm#CHDFHBHI

Thanks to Carsten Czarski for the tip.

Advertisements

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Entries and comments feeds.

%d bloggers like this: