Re: Question on Package Variables
Date: Mon, 28 Jan 2008 11:31:50 -0800 (PST)
Message-ID: <4b909fe4-fe9e-4b51-b0ad-d7be48e57861@i29g2000prf.googlegroups.com>
On Jan 24, 1:57 pm, Ed Prochak <edproc..._at_gmail.com> wrote:
> 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
>
> snip
>
> > > 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
I wouldn't use kissing or cousins. They are doing more than kissing :-)
They are not only different languages, they are different types of languages, procedural and non-procedural. They may be dressed up to kind of look the same, but it's like the difference between a woman in a dress and an ant colony in a dress. Won't look the same for long, especially if you try to kiss them. Put them together, and you have a woman covered in ants in a dress. Not likely a happy woman. But maybe a happy movie director. As always, it depends.
I think some of the problem is switching world-views between thinking in sets and thinking of records, while using what appears to be one syntax.
jg
-- @home.com is bogus. http://infiniteadmin.com/index.php/laptop-data-recovery-on-an-ssd/Received on Mon Jan 28 2008 - 13:31:50 CST