Re: Question on Package Variables

From: Ed Prochak <edprochak_at_gmail.com>
Date: Mon, 28 Jan 2008 11:50:40 -0800 (PST)
Message-ID: <0fdf0037-d59f-4206-88d4-9a837e39bc99@f10g2000hsf.googlegroups.com>


On Jan 28, 2:31 pm, joel garry <joel-ga..._at_home.com> wrote:
> 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/

I meant they were related only in that you can use SQL within PL/SQL. Otherwise I agree with your reply. I could have been much clearer. Thanks Joel.

   Ed Received on Mon Jan 28 2008 - 13:50:40 CST

Original text of this message