Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Constant declaration best practice question?

AfafasdfApr 25 2018 — edited May 2 2018

I want to code in such way that constant declarations are reusable and so can be called by other packages.  Are both methods shown below OK or is one preferred over the other due to performance, security considerations etc.?

To me method 1 is sufficient because it is takes the minimum amount of code and I don't see any security or performance problems it, when it is called in other packages.

I like to know your opinions on this.

(1.) 

CREATE OR REPLACE PACKAGE konstant IS

   k_GasAppCode CONSTANT VARCHAR2(32767) := 'GasAppln';

END konstant;

(2.)

CREATE OR REPLACE PACKAGE konstant IS

  FUNCTION k_GasAppCode RETURN VARCHAR2;

  PRAGMA RESTRICT_REFERENCES (k_GasAppCode, WNDS, RNDS, WNPS, RNPS) ;

END konstant;

CREATE OR REPLACE PACKAGE BODY konstant IS

  FUNCTION k_GasAppCode RETURN VARCHAR2 AS

  BEGIN

    RETURN 'GasAppln';

  END ;

END konstant;

This post has been answered by Manik on Apr 25 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2018
Added on Apr 25 2018
14 comments
862 views