create or replace type NUMBER_ARR is table of NUMBER;
/
create or replace TYPE ARRAY2D AS TABLE OF NUMBER_ARR;
/
create table t (id integer primary key, n array2d)
nested table n store as n_a(nested table column_value store as n_c);
insert into t values(1, array2d(number_arr(1,2), number_arr(3,4)));
insert into t values(2, array2d(number_arr(1,4)));
Select * from t
ディスプレイ:につきすべての値を表示するには
select t1.id, t3.column_value value
from t t1, table(t1.column_value) t2, table(t2.column_value) t3;
ID value
----------------
1 1
1 2
1 3
1 4
2 1
2 4
:
ID N
----------------------------
1 [unsupported data type]
2 [unsupported data type]
今すぐ、値を表示するために、あなたがテーブルに各要素を変換し、そのように参加する必要がありID、あなたはlistaggを使用することができます
select t1.id,
listagg(t3.column_value, ', ')
within group (order by t3.column_value) value
from t t1, table(t1.column_value) t2, table(t2.column_value) t3
group by t1.id;
ID value
----------------
1 1, 2, 3, 4
2 1, 4
もちろん、2次元配列のすべての要素を単一の文字列として表示しています。 適切な表示(((1,2,3,4),(4,5,6)))
のような独自のカッコ内すなわち各アレイは、あなたの現在の型定義どおりできません
これは動作しません:。
select id, '(' || listagg(value, ',')
within group (order by value) || ')' from
(select t1.id, t2.column_value c, '(' || listagg(t3.column_value, ',')
within group (order by t3.column_value) ||')' value
from t t1, table(t1.column_value) t2, table(t2.column_value) t3
group by t1.id, c)
group by id;
を作業上記のようなクエリを作成するには、あなたが持っていますオブジェクト型を定義し、map and order functionsを定義する。
最後にするために、私は、彼らがはるかに効率的なあなたは、通常のデータ型に固執すべきであると言いたい。
P.S. - ユニークキーがない場合は、rownum
またはrowid
を使用する必要があります。
あなたのコードはどこに行を見ることができ、要素を見ることはできません。 '要素の型は不透明なものとしてリストされています。 「私はテーブル全体でこれを持っていました」そのテーブルのDDLはどこですか?より詳細な情報が必要です。次に、デバッグ用のコレクションデータ型をコンパイルする理由は何ですか? –
http://prntscr.com/dogcei – Kristjan
http://prntscr.com/dogcei http://prntscr.com/dogcle http://prntscr.com/dogctc http://prntscr.com/dogcxk 最後の画像でわかるように、私は配列の値を見ることができません。そのタイプは不透明です。私はコレクションのデータ型をコンパイルする前に、私も "テーブルを見て" couldnt。それはタイプ:不透明な最初の画像allready(今はarray2d)です。 私はこれをもっと明確にしたいと思います。 – Kristjan