Solved

Oracle Session Set Time

Posted on 2013-06-28
5
728 Views
Last Modified: 2013-06-28
Dear Experts,

There is a way to set the timezone for session by using - alter session set time_zone = '+02:00'

Is there a way to set the date&time for session?  The result would be that a "select sysdate from dual" would yield a value relative to the the date&time set.

The end result is that I want to set the date&time to JAN15 and run a test based on that time.  I am not able to change the server time because it will impact others using the server.

Thanks,

Bill
0
Comment
Question by:bilpar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39284712
You cannot rewire sysdate.  It makes a hard call to the OS.

The one exception at the database level is FIXED_DATE:
http://docs.oracle.com/cd/E11882_01/server.112/e25513/initparams093.htm#REFRN10062

This will leave the servers date alone but everything in the database will think it is that date.
0
 

Author Comment

by:bilpar
ID: 39284776
Hi slightwv,

This is so very close to what I need... But, it acts at the SYSTEM level and impacts everyone on the database.  I am looking for something that acts at the SESSION level.

Thanks very much.  I did learn something new.
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39284890
I don't know of a way to have the session alter a call to sysdate.

I did see where someone wrote their own function mysysdate that returned a specific value but you would need to change all your calls from sysdate to mysysdate.

Can you not create a new 'test' database for this testing?  Then you can set it to whatever you want.
0
 

Author Comment

by:bilpar
ID: 39285011
Hi slightwv,

I am doing some work for a large company.  It takes a long time to set things up.  Lots of paperwork.  We know the code works today (with day light savings turned on).  But, we dont know for sure what will happen in November (after day light savings is turned off).

I was looking for a way to test TIMESTAMP with LOCAL ZIME ZONE columns.  If we cannot do that then we will GO LIVE in 2 weeks.  In the meantime, we will setup the dedicated test server and change the date and the test to make sure the code works... prior to the November of course.

Thanks for you assist,

Bill
0
 

Author Closing Comment

by:bilpar
ID: 39285013
Hi slightwv,

I am doing some work for a large company.  It takes a long time to set things up.  Lots of paperwork.  We know the code works today (with day light savings turned on).  But, we dont know for sure what will happen in November (after day light savings is turned off).

I was looking for a way to test TIMESTAMP with LOCAL ZIME ZONE columns now.  If we cannot do that then we will GO LIVE in 2 weeks.  In the meantime, we will setup the dedicated test server and change the date and the test to make sure the code works... prior to the November of course.

Thanks for you assist,

Bill
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to recover a database from a user managed backup
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question