--create a type with number datatype
SQL> create or replace type type1
2 is table of number;
3 /
Type created.
--Create function for generating numbers and assign them in the type TYPE1
--Return the list
SQL> create or replace function function1(n IN number)
2 return type1
3 as
4 list_1 type1:= type1(0);
5 i number;
6 begin
7 for i in 1..n
8 loop
9 list_1(i):=i;
10 list_1.extend;
11 end loop;
12
13 return list_1;
14 end;
15 /
Function created.
--Now table() casting would help us list the values in table-like format
SQL> Select * from table(function1(10))
2 where column_value is not null;
COLUMN_VALUE
------------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL>
SQL> create or replace type type1
2 is table of number;
3 /
Type created.
--Create function for generating numbers and assign them in the type TYPE1
--Return the list
SQL> create or replace function function1(n IN number)
2 return type1
3 as
4 list_1 type1:= type1(0);
5 i number;
6 begin
7 for i in 1..n
8 loop
9 list_1(i):=i;
10 list_1.extend;
11 end loop;
12
13 return list_1;
14 end;
15 /
Function created.
--Now table() casting would help us list the values in table-like format
SQL> Select * from table(function1(10))
2 where column_value is not null;
COLUMN_VALUE
------------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL>
Comments