Re: CASTING

From: ddf <oratune_at_msn.com>
Date: Tue, 8 Nov 2011 12:27:40 -0800 (PST)
Message-ID: <6efa25cf-0ae7-44b2-9ed3-fc75414db9ae_at_h5g2000yqk.googlegroups.com>



On Nov 3, 10:43 am, ExecMan <artme..._at_yahoo.com> wrote:
> Hi,
>
> I just wanted to understand something about the SQL / PLSQL
> environments.  Often we store things into a PL/SQL table and then
> using CAST we can select from them as if they were real tables.  To do
> this however, we need to define an object type, outside of the package
> we are using.
>
> Why can we not define the type within the package specification and
> then use it later in the package?
>
> In many of our packages we declare a REF CURSOR type in the package
> specification like this, and then use it all over the package:
>
> TYPE ref_crs IS REF CURSOR;
>
> So, if I wanted to declare an object type, why must you actually
> create the object type outside the package?
>
> TYPE result_type IS RECORD (
>   customer_id  VARCHAR2(6),
>   result            NUMBER);
>
> TYPE result_table IS TABLE OF result_type;
>
> Then in the package:
>
> v_result_table   portfolio_result_table := portfolio_result_table();
>
> One can create record types within the same package and use them.
> What is so different about the objects that they must be defined
> outside?
>
> Thanks.

It isn't possible to define an object type within a PL/SQL unit since it must be created. Creating the object type would be in the body of a PL/SQL block (using dynamic sql) so it can't be used in the 'define' section as it wouldn't yet exist.

David Fitzjarrell Received on Tue Nov 08 2011 - 14:27:40 CST

Original text of this message