1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29create or replace function test_query_func(dept varchar2)
return clob
is
type test_record is record
(rec_empno emp.empno%type,
rec_ename emp.ename%type,
rec_job emp.job%type,
rec_sal emp.sal%type);
type test_query_arr is table of test_record index by binary_integer;
cursor cur is select empno, ename, job, sal from emp where deptno = dept;
test_query test_query_arr;
i integer := 0;
ss varchar2(200) := '';
res clob := '[';
begin
for c in cur loop
i := i + 1;
test_query(i) := c;
end loop;
for q in 1..test_query.count loop
ss := '(''' || test_query(q).rec_empno || ''', ''' || test_query(q).rec_ename || ''', ''' || test_query(q).rec_job || ''', ''' || test_query(q).rec_sal || ''')';
if q < test_query.count then
ss := ss || ',';
end if;
res := res || ss;
end loop;
res := res || ']';
return res;
end;