You Asked
How can I make a global package variable (in the package spec) as read-only?
Yes, I can define it as a CONSTANT, but what I want is to initialize it once in the package body and then have users just read it, not modify it?
create or replace package p
as
type plsql_table_t is table of varchar2(2000) index by binary_ingeger;
mytab plsql_table_t;
end;
/
create or replace package body p
as
begin
select ... into mytab from ...
end;
/
How can I make it such that users can read p.mytab but not modify it?
Thanks
and Tom said...
In the same manner you would in any language.
you would code "getter" and "setter" functions -- that is, it would be returned to them via a function. If you want them to be able to write it, you would code a "setter" function.
But you would move this variable into the BODY (hide it), and provide a function that returns it.
Rating
(1 rating)
Is this answer out of date? If it is, please let us know via a Comment