Link to home
Start Free TrialLog in
Avatar of ajaybelde
ajaybeldeFlag for United States of America

asked on

is there a way i define constant globally in oracle

I want to define a constant or some macro defined value  in oracle db and use it globally or at schema level. is that possible by any means.
Here was a macro defined for IPNEWVAL address lengths we want  use in various places (db definitions and SPs).

is there a way i can define a value to IPNEWVAL=say some value 120 and use the defined IPNEWVAL in SP,Trigger or constarints

ex: instead of giving constant value 120. i want pas IPNEWVAL which is defined already using that my contsraint can get the value.
CHECK (name NOT MATCHES '' AND LENGTH(name) <= IPNEWVAL)
SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sean Stuber
Sean Stuber

in 12c you can reference the package variable in sql without needing the pl/sql function.
You might want to declare it as a constant though instead of just another variable.
Avatar of ajaybelde

ASKER

sdstuber: how would i call the context in trigger. and also i just want to use the conext has a fixed constant like number 100. and should be able to call it in trigger and SP
any time you need to find the value you use

SYS_CONTEXT('mycontext','ipnewval')


whether in a trigger, sql statement, constraint, pl/sql function, etc
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and also can we use Types here?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
your's suggestion was helpful and i was able to help appteam