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: function get_org_for_config_content (
8: config_content_id_in in number
9: ) return number;
10: procedure set_org_quota_total (
11: org_id_in in number,
12: total_in in number
13: );
14: procedure update_org_quota (
15: org_id_in in number
16: );
17: 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: return retval;
28: end recompute_org_quota_used;
29: function get_org_for_config_content (
30: config_content_id_in in number
31: ) return number is
32: org_id number;
33: begin
34: select cc.org_id
35: into org_id
36: from rhnConfigChannel cc,
37: rhnConfigFile cf,
38: rhnConfigRevision cr
39: where cr.config_content_id = config_content_id_in
40: and cr.config_file_id = cf.id
41: and cf.config_channel_id = cc.id;
42: return org_id;
43: end get_org_for_config_content;
44: procedure set_org_quota_total (
45: org_id_in in number,
46: total_in in number
47: ) is
48: available number;
49: begin
50: select total_in + oq.bonus
51: into available
52: from rhnOrgQuota oq
53: where oq.org_id = org_id_in;
54: rhn_config.prune_org_configs(org_id_in, available);
55: update rhnOrgQuota
56: set total = total_in
57: where org_id = org_id_in;
58: exception
59: when no_data_found then
60: insert into rhnOrgQuota ( org_id, total )
61: values (org_id_in, total_in);
62: when others then
63: null;
64: end set_org_quota_total;
65: procedure update_org_quota (
66: org_id_in in number
67: ) is
68: begin
69: update rhnOrgQuota
70: set used = rhn_quota.recompute_org_quota_used(org_id_in)
71: where org_id = org_id_in;
72: end update_org_quota;
73: end rhn_quota;