Thank you very much for your answer!
If we use some values as constants in our code (numbers or strings etc) this value must be declared as constant because
1. It can be needed anywhere else
2. the value of this constant can be changed sometimes
3. this makes code more clean and understandable (
c_green
much more better than just '1' for example)
I was taught in such way.
This is centralization, one point of control, encapsulation. We just provide the interface.
In situation like
sys_context('APP_NS', 'USER_Id')
vs
sys_context('APP_NS', 'USERID')
sys_context(my_pkg.c_ns, my_pkg.c_user_id)
protects from error
ctx_api.get_user_id
excludes error
In this case we also avoiding hard code.
So this are the aims which I've tried to reach:
1. gather code which works with context in one place
2. encapsulate details
3. Avoid misprints
Also, there can be a lot of constants, application can be huge.
I'm worrying about redundancy\practicalness.
I understand, that this wrapper is additional call, additional context switch and it can't be easily used in views for example
Writing answer I payed attention to constant naming. Of course
c_user_id constant varchar2(30):='user_id'
is redundant.
In this case changing value changes meaning and requires to change name too. So c
_updater
or
c_user
is more useful in such case.
What I'm interested for is
1. Does this approach make sense
2. With relation to your experience, is it totally bad or it can be useful.
3. What way will be better?