aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_get_rateplan_amount
Parameters
Name
Type
Mode
rateplan_id
integer
IN
roomtype_id
integer
IN
Definition
declare link_id int; declare link_amt t_money; declare link_type smallint; declare rate_amt t_money; declare rate_result t_money; declare loop_count smallint; begin rate_amt = null; rate_result = 0; link_id = 0; loop_count = 0; while (loop_count < 10 and link_id is not null) loop select link_plan_id, link_adjust_type, link_adjust_amt from rate_plan where id = rateplan_id into link_id, link_type, link_amt; if link_id is null then rate_amt = (select rate_amount from rate_details d where d.rateplan_id = link_id and d.roomtype_id = $2); rate_result = rate_result + case link_type when 1 then rate_amt + (rate_amt * link_amt / 100.00) when 2 then rate_amt + link_amt end; else rateplan_id = link_id; end if; loop_count = loop_count +1; END LOOP; return rate_result; END;