CASTING

From: ExecMan <artmerar_at_yahoo.com>
Date: Thu, 3 Nov 2011 11:43:26 -0700 (PDT)
Message-ID: <2f2068cb-0d6f-4210-9bca-ac01fdf4525c_at_g7g2000vbv.googlegroups.com>



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. Received on Thu Nov 03 2011 - 13:43:26 CDT

Original text of this message