1: function hp_user_quota_max (userid IN integer, lesser_mortal_quota IN integer, higher_mortal_quota IN integer, higher_mortal_p IN integer)
2: return integer
3: IS
4: quota_max integer;
5: special_count integer;
6: return_value integer;
7: BEGIN
8: select count(*) into special_count
9: from users_special_quotas
10: where user_id=userid;
11:
12: IF special_count = 0
13: THEN
14: IF higher_mortal_p = 0
15: THEN
16: select (lesser_mortal_quota * power(2,20))
17: into return_value
18: from dual;
19: return return_value;
20: ELSE
21: select (higher_mortal_quota * power(2,20))
22: into return_value
23: from dual;
24: return return_value;
25: END IF;
26: ELSE
27: select max_quota into quota_max
28: from users_special_quotas
29: where user_id=userid;
30: select (quota_max * power(2,20))
31: into return_value
32: from dual;
33: return return_value;
34: END IF;
35: END;
|