Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Package Constants vs Literals
klabu wrote:
> "joel garry"
> > See
> >
> http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:7832114438832
> > to see how to figure out if it works for your exact code. Especially
> > note the first and Sept. 13, 2006 responses.
>
> 1st:: 10gR2
> 2nd: Yes, Know all about Tom's mantra on BV.
>
> Let me make it a bit more clear about what I'm asking about.
>
> I'm NOT taking about in the context of an "application"
> Just about AD_HOC SQL (or a view) some "programmer/analyst" would write....
>
> Is it a good practice to replace literal codes (i.e 'AWD','FBW','UEM')
> with pkg constants :
>
> create package our_business_costants
> is
> begin
> all_wheel_drive constant varchar2(30) := 'AWD' ;
> fly_by_wire constant varchar2(30) := 'FBW' ;
> unearned_extortion_money constant varchar2(30) := 'UEM' ;
> end ;
>
> select * from sometable
> where drivetype = our_business_costants.all_wheel_drive
> and avinoicstype = our_business_costants.fly_by_wire
> and fundsource = our_business_costants.unearned_extortion_money ;
>
> Bascially I'm talking about EASE OF UNDERSTANING for say a new employee who
> have no idea
> what codes are available and WTH they mean.
I once had a guru, who had a guru, who always asked
where do I put it, do I put in a table or in a function?
His answer of course
If you want to make it transparent, and understandable and easily
modifiable, put it in a table.
Assuming you (like everyone else) never document you code, the fragment
you posted above only causes Repetitive Strain Injury, and is a
nightmare even if you use copy and paste.
Perfect example to convert into a table. Probably a PL/SQL table, but a
table anyway.
Other than that the issue you raised above has nothing to do with PL/SQL. If these are really your coding standards, I can hear that new employee banging his head against a wall here.
-- Sybrand Bakker Senior Oracle DBAReceived on Fri Oct 20 2006 - 07:14:25 CDT