2008-02-03

Fixing the sysdate for testing

When we create a test bunch (for instance with Quest Code Tester) we need to make sure that if we use the sysdate function in the code we will test that the sysdate function gets a certain value.


For that we can use in the initialization section of the test

alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
alter system set fixed_date = '2008-02-04 14:30:00';

and put it back in the cleanup

alter system set fixed_date = 'none';

For that we need that the user has the alter system permission.

Notice: This fixes the sysdate to that date and will not increment for the instance (all sessions). Code that checks the time spent will give 0! This should not be used (due to be a alter system) in a production system!

No comments:

Post a Comment

Os comentários são moderados.
The comments are moderated.