RHN_QUOTA
DDL scriptPackage source
Legend: string keyword reserved word operator
1: package
2: rhn_quota
3: is
4: function recompute_org_quota_used (
5: org_id_in in number
6: ) return number;
7:
8: function get_org_for_config_content (
9: config_content_id_in in number
10: ) return number;
11:
12: procedure set_org_quota_total (
13: org_id_in in number,
14: total_in in number
15: );
16:
17: procedure update_org_quota (
18: org_id_in in number
19: );
20: end rhn_quota;
Package body source
Legend: string keyword reserved word operator
1: package body
2: rhn_quota
3: is
4: function recompute_org_quota_used (
5: org_id_in in number
6: ) return number is
7: retval number := 0;
8: begin
9: begin
10: select NVL(sum(a.file_size),0)
11: into retval
12: from (
13: select distinct content.id, content.file_size
14: from rhnConfigContent content,
15: rhnConfigRevision cr,
16: rhnConfigFile cf,
17: rhnConfigChannel cc
18: where cc.org_id = org_id_in
19: and cc.id = cf.config_channel_id
20: and cf.id = cr.config_file_id
21: and cr.config_content_id = content.id
22: ) a;
23: exception
24: when others then
25: null;
26: end;
27:
28: return retval;
29: end recompute_org_quota_used;
30:
31: function get_org_for_config_content (
32: config_content_id_in in number
33: ) return number is
34: org_id number;
35: begin
36:
37: select cc.org_id
38: into org_id
39: from rhnConfigChannel cc,
40: rhnConfigFile cf,
41: rhnConfigRevision cr
42: where cr.config_content_id = config_content_id_in
43: and cr.config_file_id = cf.id
44: and cf.config_channel_id = cc.id;
45:
46: return org_id;
47: end get_org_for_config_content;
48:
49: procedure set_org_quota_total (
50: org_id_in in number,
51: total_in in number
52: ) is
53: available number;
54: begin
55: select total_in + oq.bonus
56: into available
57: from rhnOrgQuota oq
58: where oq.org_id = org_id_in;
59:
60: rhn_config.prune_org_configs(org_id_in, available);
61:
62: update rhnOrgQuota
63: set total = total_in
64: where org_id = org_id_in;
65: exception
66: when no_data_found then
67: insert into rhnOrgQuota ( org_id, total )
68: values (org_id_in, total_in);
69:
70:
71:
72:
73:
74:
75: when others then
76: null;
77: end set_org_quota_total;
78:
79: procedure update_org_quota (
80: org_id_in in number
81: ) is
82: begin
83: update rhnOrgQuota
84: set used = rhn_quota.recompute_org_quota_used(org_id_in)
85: where org_id = org_id_in;
86: end update_org_quota;
87: end rhn_quota;