-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite_donar_address.sql
35 lines (33 loc) · 1.16 KB
/
write_donar_address.sql
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
29
30
31
32
33
34
35
set serveroutput on
declare
f utl_file.file_type;
num integer;
cnt integer;
d_id integer;
d_blood Donar.blood_group%type;
type don_bl is varray (11) of Donar.donar_address%type;
dbl_list don_bl := don_bl();
begin
num := 1;
cnt := 1;
dbl_list.extend(11);
FOR cursor1 IN (select distinct(donar_address) as address from donar)
LOOP
dbl_list(num) := cursor1.address;
num:=num+1;
END LOOP;
while cnt<=num
loop
f:= utl_file.fopen('BBMS',concat(to_char(dbl_list(cnt)),'_donar.csv'),'w');
utl_file.put(f,'id'||','||'name'||','||'blood'||','||'contact'||','||'place');
utl_file.new_line(f);
for c_record in (select donar_id,donar_name,blood_group,donar_contact_no,donar_address from donar where donar_address = dbl_list(cnt))
loop
utl_file.put(f,c_record.donar_id||','||c_record.donar_name||','||c_record.blood_group||','||c_record.donar_contact_no||','||c_record.donar_address);
utl_file.new_line(f);
end loop;
utl_file.fclose(f);
--dbms_output.put_line(dbl_list(cnt));
cnt:=cnt+1;
end loop;
end;