dbTalk Databases Forums  

CASTING

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss CASTING in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ExecMan
 
Posts: n/a

Default CASTING - 11-03-2011 , 12:43 PM






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.

Reply With Quote
  #2  
Old   
ddf
 
Posts: n/a

Default Re: CASTING - 11-08-2011 , 02:27 PM






On Nov 3, 10:43*am, ExecMan <artme... (AT) yahoo (DOT) com> wrote:
Quote:
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.