Thread: Is there a type like a growable array, similar Vector at Java language in postgreSQL?
Is there a type like a growable array, similar Vector at Java language in postgreSQL?
From
"Dongsoo Yoon"
Date:
In Oracle, there is a type like a growable array, similar Vector at Java language.
In postgreSQL, is there any type like bellow type?
---------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE test(
p_size in number
,p_proccode out varchar2
,p_procmesg out varchar2
)
IS
v_count number default 0;
v_dayIndex number default 0;
v_size number default 0;
type tb_NumTable is table of number(2) index by binary_integer;------------>like a growable array
t_modifiedTimes tb_NumTable;----------------------------------------------->declare a variable using above defined type.
....
v_dayIndex number default 0;
v_size number default 0;
type tb_NumTable is table of number(2) index by binary_integer;------------>like a growable array
t_modifiedTimes tb_NumTable;----------------------------------------------->declare a variable using above defined type.
....
BEGIN
....
v_size := nvl(p_size, 0);
for v_count in 1..v_size loop
v_dayIndex := v_dayIndex + 1;
t_modifiedTimes[v_dayIndex ] := v_count;
end loop;
....
p_proccode := 0;
p_procmesg := 'OK';
EXCEPTION
WHEN OTHERS THEN
p_proccode := SQLCODE;
p_procmesg := SUBSTR(SQLERRM, 1, 255);
p_proccode := 0;
p_procmesg := 'OK';
EXCEPTION
WHEN OTHERS THEN
p_proccode := SQLCODE;
p_procmesg := SUBSTR(SQLERRM, 1, 255);
end test;
Dongsoo Yoon wrote: > In Oracle, there is a type like a growable array, similar Vector at > Java language. I always find the manuals good for this information. Looking in the section on "Arrays", in "Data Types" BEGIN QUOTE A stored array value can be enlarged by assigning to an element adjacent to those already present, or by assigning to a slice that is adjacent to or overlaps the data already present. For example, if array myarray currently has 4 elements, it will have five elements after an update that assigns to myarray[5]. Currently, enlargement in this fashion is only allowed for one-dimensional arrays, not multidimensional arrays. END QUOTE Is that helpful? -- Richard Huxton Archonet Ltd