Referencing package variables from sql statements

From: Jetlag <jetlag11235_at_yahoo.com>
Date: 3 Oct 2002 08:10:27 -0700
Message-ID: <2eeed00e.0210030710.f1e1484_at_posting.google.com>


I am using Oracle 9.2 under Linux. I have created a package mp (example below) of configuration variables, and would like to access it in pure SQL statements. For example, I would like to access variable x:

   SELECT mp.x FROM dual;

This results in the error 'x' is not a procedure or is undefined. Creating a wrapper function f gets around this problem -- see below:

   SELECT mp.f FROM dual;

However, I fear that this adds overhead I would prefer to avoid. Is there a logical alternative to directly access package variables?

///////////////////////////////

CREATE OR REPLACE PACKAGE mp IS

   x CONSTANT NUMBER(1) := 1;
   FUNCTION f RETURN NUMBER;
END mp;
/
PACKAGE BODY mp AS

   FUNCTION f RETURN NUMBER IS
   BEGIN
      RETURN x
   END f;
END mp;
///////////////////////////////

Thanks for the help.

  • Jetlag
Received on Thu Oct 03 2002 - 17:10:27 CEST

Original text of this message