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!

PL/SQL help for Constant in package level

pkpandaJul 26 2017 — edited Jul 26 2017

Hi All,

I just want to clarify one development practice.

Is it a good practice to define thousands of CONSTANT at package level to define the error number which is stored in a table.

CREATE PACKAG _public_pkg IS

my_constant1 CONSTANT INTEGER := 999;

my_constant2 CONSTANT INTEGER := 998;

Then you this constant in individual function to return the error number then one common function will be called to read the error message from the table base on the number and display the message.

My suggation is that

create package abc_public_pkg is

Function f1 return number ;

end;

create package body abc_public_pkg is

Function f1 return number

as

begin

  if 1!=2 then

     return 999;

  else

     return 998;

  end if ;

END;

END;

end;

Other people

create package abc_public_pkg is

c1 CONSTANT INTEGER := 1;

...

c999 CONSTANT INTEGER := 999;

c998 CONSTANT INTEGER := 998;

-- more than 1000 error messages are there and it will grow.

end;

create package body abc_public_pkg is

Function f1 return number

as

begin

  if 1!=2 then

  return c999;

  else

  return c998;

  end if ;

end;

END;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2017
Added on Jul 26 2017
10 comments
5,287 views