create or replace function f_get_amount_correctionticket (packingnoteid 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);
return lv_amount;
end f_get_amount_correctionticket;
/
