Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question.

Asked: September 11, 2004 - 7:26 pm UTC

Last updated: September 12, 2004 - 9:59 pm UTC

Version: 9.2.0

Viewed 1000+ times

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

Comments

Thanks

A reader, September 12, 2004 - 9:59 pm UTC


More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library