我创建了表格,通过其中一个嵌套表格进行链接:
function somemethod(value){
#{backingbean.test(value)}
}
现在我需要CREATE VIEW来显示表B中来自A的嵌套数据的数据。它类似于
CREATE TABLE A (
NAME VARCHAR(150) ,
ID INTEGER PRIMARY KEY
) ;
CREATE TYPE A_LIST IS TABLE OF integer;
CREATE TABLE B (
NAME VARCHAR(150),
ID INTEGER PRIMARY KEY,
LIST A_LIST
) NESTED TABLE LIST STORE AS LIST_TABLE;
但我被困在那个点(
答案 0 :(得分:0)
如果你想根据嵌套ID加入表B和A - 这里是一个例子。
一些测试数据
insert into b
values ('x',1, A_LIST(1,2,3));
insert into a values ('A1',1);
insert into a values ('A2',2);
insert into a values ('A3',3);
主要步骤是表B与嵌套表from b, table(b.list)
的连接。嵌套ID返回为COLUMN_VALUE
;休息是简单的加入
select b.id, b.name, a.name a_name, a.id a_id from b, table(b.list) ba, a
where ba.column_value = a.id;
结果
ID SUBSTR(B.NAME,1,5) A_NAME A_ID
---------- ------------------ ------ ----------
1 x A1 1
1 x A2 2
1 x A3 3
答案 1 :(得分:0)
create type record_for_a is object( a varchar2(150), id number);
create type l_record_for_a is table of record_for_a;
select table_b.name, table_b.id,
cast( multiset (select record_for_a(aa.name,aa.id) from a aa, table(table_b.list) bb where aa.id = bb.column_value) as l_record_for_a)
neste_col_a
from
b table_b;