-
Notifications
You must be signed in to change notification settings - Fork 24
/
exists.plsql
52 lines (38 loc) · 1.01 KB
/
exists.plsql
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
declare
type r is record (
nm number,
vc varchar2(20)
);
type t is table of r index by varchar2(10);
v t;
procedure out_1 (key_ in varchar2) is -- {
begin
dbms_output.put_line(key_ || ': ' || v(key_).nm || ' - ' || v(key_).vc);
exception
when no_data_found then
dbms_output.put_line('No entry found for ' || key_);
when others then
raise;
end out_1; -- }
procedure out_2 (key_ in varchar2) is -- {
begin
if v.exists(key_) then
dbms_output.put_line(key_ || ': ' || v(key_).nm || ' - ' || v(key_).vc);
else
dbms_output.put_line('No entry found for ' || key_);
end if;
end out_2; -- }
begin
v('foo').nm := 42; v('foo').vc := 'forty-two';
v('bar').nm := 11; v('bar').vc := 'eleven';
dbms_output.new_line;
out_1('foo');
out_1('bar');
out_1('baz');
dbms_output.new_line;
out_2('foo');
out_2('bar');
out_2('baz');
dbms_output.new_line;
end;
/