Database Global Variable


Is there a way to set up a variable that is stored and used again and again in the database (Oracle).  I want to set the financial Year to 2017.  It's used over and over again in stored procedures and views etc...  When it's changed, it should be changed in everything.

Like a global variable but where do you declare it etc...

Kind regards,
Coco BeansDesignerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martyn SpencerSoftware Developer / Linux System Administrator / Managing DirectorCommented:
You could create a package that contains the constant. To ensure that it can be referenced in SQL, wrap it in a function. My reason for suggesting a package is that you could call it something like "app_constants" and then place all of your constant definitions there. If you only have one constant, just create a function. Let me know if you need an example.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NorieAnalyst Assistant Commented:

As far as I know Oracle doesn't support global variables but what you could do is create a function that returns the value you want.

Something like this perhaps.

    RETURN 2017
END fin_year;
Coco BeansDesignerAuthor Commented:
Perfect - thank you
Martyn SpencerSoftware Developer / Linux System Administrator / Managing DirectorCommented:
You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.