0

I've recently discovered the feature of defining global variables for DB2. I wanted to utilize it. My use case is to create a variable containing the value for Previous Banking day.

 CREATE VARIABLE SCHEMA.GV_PREV_PROC_DATE DATE
 DEFAULT ((SELECT SCHEMA.DATE_UTIL.PREVIOUS_BANKING_DAY(PROC_DATE) 
           FROM SCHEMA.TBL_PARAMETERS));     

This particular date is usually referenced throughout various programs. Instead of querying everytime, I thought of placing it in the variable. Based on the DB2 specification, the value is session scoped. Since we utilize datsource pooling, the value is not updated once the date is incremented by the end of day batch program, unless i reset my connection pool.

Is there a way to propagate the updates to existing sessions, or is my use case totally not appropriate for this global variables? By the way I'm using DB2 10.1 LUW

0

You can set variables to a new value in a session but you would need your application to spot the date change and update the variable for the session accordingly. Or alternatively, kill all sessions when the date changes!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.