Home » SQL & PL/SQL » SQL & PL/SQL » Backward accessing super type's attributes from sub type body in oracle collection (Types) (Oracle 10g)
Backward accessing super type's attributes from sub type body in oracle collection (Types) [message #573661] Wed, 02 January 2013 03:14 Go to next message
prabakaran.sr
Messages: 2
Registered: January 2013
Junior Member
hello eveyone..

I have 3 user defined collection types. I am trying to access the type3's attribute in type1 body (like backward accessing).

Ex. My Collection Types Structure (something like master detail structure)

create type type1 as object
(
attr1 varchar2(10),
attr2 varchar2(10),
member procedure function1
)
/
create type type1_colc as table of type1
/

create type type2 as object
(
attr1 varchar2(10),
attr2 varchar2(10),
oc_t1 type1_colc,
member procedure function1
)
/
create type type2_colc as table of type2
/

create type type3 as object
(
attr1 varchar2(10),
attr2 varchar2(10),
oc_t2 type2_colc,
member procedure function1
)
/
so, in the type1 body i have to get or assign the value either to type2's attribute or type3's attribute. I have search all the in internet but i haven't find anything such. Someone please help me how to find the reverse method of accessing the super type's attribute(s) in sub type's body.
Re: Backward accessing super type's attributes from sub type body in oracle collection (Types) [message #573667 is a reply to message #573661] Wed, 02 January 2013 03:35 Go to previous messageGo to next message
Michel Cadot
Messages: 57612
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
type1 type has no reference to type2 or type3, so how could it assign something to them?
I'd undestand if you ask how to assign type1 attributes from a type2 or type3 variable as both contain reference to type1 but the opposite seem meaningless.
Your question is not clear.
Post an example of what you want to do.

Regards
Michel
Re: Backward accessing super type's attributes from sub type body in oracle collection (Types) [message #573675 is a reply to message #573667] Wed, 02 January 2013 04:39 Go to previous messageGo to next message
prabakaran.sr
Messages: 2
Registered: January 2013
Junior Member
Dear Michel,

Actually we converting the code from oracle forms code to back end using oracle collections.
Lets say in a form contain master detail relationship as block1, block2 & block3 is block3 and the relationship.

As mentioned in previous post i have 3 types. The 3rd type is the main type in other way can say as super type and type2 is sub type of type3. Type2 will be a super type of type1 in other way type1 is sub type of type2. Here i am not using the inheritance.

The type1 i am converting as collection type as table and implementing it in type2 same way the type2 also and i implenting in type3. Both type2 and type1 has reference in type3.

But my question is "from type1 body i need a value from type3 and how can i access that?

something like
----------------------------------------------------------------------
--type1 body as sub type
--**** "Constructor" i haven't mentioned in the previous post
----------------------------------------------------------------------
create or replace type body type1 as
constructor function type1 return self as result is
begin
return;
end;
member procedure function1 is
lv_value varchar2(1000);
begin
if type3.attr1 = 'A' then ----> here i need to get the value from type3 attribute value.
lv_value := self.attr1 || self.attr2;
end if;
end;
end;
----------------------------------------------------------------------
--type3 body as super type / main type
--**** "Constructor" i haven't mentioned in the previous post
----------------------------------------------------------------------
create or replace type body type3 as
constructor function type1 return self as result is
begin
return;
end;
member procedure function1 is
begin
self.attr1 := 'A'; -- in the super type i will assing the value or from table at run time. This value i have to
-- read in above type1 body.
end;
end;
----------------------------------------------------------------------
Re: Backward accessing super type's attributes from sub type body in oracle collection (Types) [message #573677 is a reply to message #573675] Wed, 02 January 2013 04:58 Go to previous message
Michel Cadot
Messages: 57612
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I don't know Forms but what I can say is that you cannot refer type3 in type1 type because type1 do not refer to type3.

In addition, what your code describes are not supertype or subtype but just a type that is an attribute of another type, there is no hierarchy of types.

So I conclude your model is wrong but as I said I don't know Forms and so can't help you to migrate in this way. Anyway, I'd not go to object method for this unless you have a real expert on this feature (which does not seem to be the case).

Regards
Michel
Previous Topic: Oracle query error
Next Topic: Error handling inside Cursor
Goto Forum:
  


Current Time: Sat Apr 19 09:59:10 CDT 2014

Total time taken to generate the page: 0.08507 seconds