create or replace function f_get_amount_corrticketline (packingnoteid number, productid number, sizeid number, fmid number)
return number is
lv_amount number;
begin
select nvl(sum(pnl.deliveredamount),0) into lv_amount
         from packingnoteline pnl
         where PNL.PACKINGNOTE_ID in
               (select PN.PACKINGNOTE_ID
                  from PACKINGNOTE PN
                 where PN.CORRECTIONFORNOTE_ID = packingnoteid)
               and pnl.product_id = productid
               and pnl.sizedefinition_id = sizeid
               and pnl.finishingmethod_id = fmid;
return lv_amount;
end f_get_amount_corrticketline;
/
