次の2-D ARRAYデータ型およびテーブルについて考えてみましょう。
CREATE TYPE shot_ary AS VARRAY(1:50)(1:50) OF INTEGER; CREATE TABLE seismic_table ( id INTEGER, shots shot_ary);
テーブルには次の値が取り込まれます。
/* The first 2 elements are populated; the rest are uninitialized. */ INSERT INTO seismic_table VALUES (1, shot_ary(11, 12)); /* Empty ARRAY instance */ INSERT INTO seismic_table VALUES (2, shot_ary()); /* Update empty ARRAY instance such that element [1][3] is set to a value; Then elements [1][1] and [1][2] are set to NULL, the rest are uninitialized */ UPDATE seismic_table SET shots[1][3] = 1133 WHERE id = 2;
次の問合わせは、shots配列に取り込まれた構成要素の最大の添字値を返します。
SELECT id, shots.OLAST() FROM seismic_table;
問合わせの結果を次に示します。
ID shots.OLAST() -- ------------------ 1 NEW arrayVec(1,2) 2 NEW arrayVec(1,3)