Reputation: 60027
I have the following code:
create or replace type t_gib force as object (
fld number,
member function f return number
) not final;
/
declare
type tab_bin is table of pls_integer index by pls_integer;
type t_rec is record (
f1 t_gib
,f2 tab_bin
,f3 tab_bin
,f4 t_gib
);
--
l_rec t_rec;
begin
l_rec.f2(1) := 5;
l_rec.f2(2) := 7;
l_rec.f3(1) := 9;
--
dbms_output.put_line(l_rec.f2.count || '-' || l_rec.f3.count);
dbms_output.put_line(l_rec.f2(l_rec.f2.last) || '-' || l_rec.f3(l_rec.f3.last));
end;
/
This does not compile. But it compiles if I remove the not final
.
Additionally it also compiles if I just re-arrange the record thus
type t_rec is record (
f2 tab_bin
,f3 tab_bin
,f4 t_gib
,f1 t_gib
);
Does anybody have an explanation for this behaviour?
Upvotes: 0
Views: 123
Reputation: 10648
Most likely your have some other business going on there as your example works fine (11gR2). Please see the full working example below. I guess you should also drop force
and not final
keywords unless you know what you're doing, but they should have no effect in this example.
Test type
create or replace type foo_t force is object (
m_f number
,member function f return number
) not final;
/
show errors
create or replace type body foo_t is
member function f return number is
begin
return m_f;
end;
end;
/
show errors
Example use
declare
type int_int_hash_t is table of pls_integer index by pls_integer;
type bar_t is record (
b1 foo_t
,b2 int_int_hash_t
,b3 int_int_hash_t
,b4 foo_t
);
v_bar bar_t;
begin
v_bar.b1 := foo_t(1);
v_bar.b2(2) := 2;
v_bar.b3(3) := 3;
v_bar.b4 := foo_t(4);
dbms_output.put_line(v_bar.b1.f);
dbms_output.put_line(v_bar.b2(2));
dbms_output.put_line(v_bar.b3(3));
dbms_output.put_line(v_bar.b4.f);
end;
/
Results
SQL> @so62.sql
No errors.
1
2
3
4
PL/SQL procedure successfully completed.
SQL>
Upvotes: 1