Re: Question on Package Variables
Date: Thu, 24 Jan 2008 13:57:20 -0800 (PST)
On Jan 24, 11:01 am, Galen Boyer <galen_bo..._at_yahoo.com> wrote:
> On Thu, 24 Jan 2008, sybra..._at_gmail.com wrote:
> > On Jan 24, 2:37 pm, Galen Boyer <galen_bo..._at_yahoo.com> wrote:
> >> CREATE OR REPLACE PACKAGE p_tst
> >> IS
> >> v_var int := 1;
> >> END;
> >> /
> >> SQLPLUS> select p_tst.v_var from dual;
> >> The above fails with an error of p_tst not a function (or something
> >> to that affect).
> >> Is this based on the variable only being available in the PLSQL
> >> engine and not available in SQL or something else?
> >> --
> >> Galen Boyer
> > Secondly:
> > You can't access PL/sql variables outside pl/sql even if they are in a
> > package spec.
> I understand that. Was just wondering if there was a why.
Because that is the way PL/SQL is designed. Packages provide encapsulation. It's very different from programming is something like BASIC. and yes the variable is not available to SQL because the interface between SQL (e.g. sqlplus or embedded SQL) and PL/SQL is by invoking a FUNCTION in a SQL statement or executing a PROCEDURE. SQL and PL/SQL are different languages (though they kissing cousins).
Ed Received on Thu Jan 24 2008 - 15:57:20 CST