UPDATE YDET 
 SET YDET_FINALAMOUNT=GETYDETDISCOUNTEDAMOUNTTMP(NVL(YDET_RATEAMOUNT,NVL(YDET_RATEMANUAL,0)),YDET_RATEMANUAL,YDET_RATEDIFF,YDET_RATEDISCOUNTPERC,YDET_NODISCOUNTPACKAGE)
,YDET_FINALFOREIGNAMOUNT=GETYDETDISCOUNTEDAMOUNTTMP(NVL(YDET_FOREIGNRATEAMOUNT,YDET_FOREIGNRATEMANUAL),YDET_FOREIGNRATEMANUAL,YDET_FOREIGNRATEDIFF,YDET_RATEDISCOUNTPERC,YDET_FOREIGNNODISCOUNTPACKAGE)
WHERE YDET_FINALAMOUNT IS NULL;
 
ALTER TABLE YDET MODIFY YDET_FINALAMOUNT NOT NULL;

DROP FUNCTION GETYDETDISCOUNTEDAMOUNTTMP;

UPDATE YPCF SET YPCF_CREATEDINHOTEL=  
 NVL((SELECT WPHS_NAME FROM WPHS,XCMS WHERE WPHS_ID=XCMS_ORG_WPHS_ID AND XCMS_ID=YPCF_XCMS_ID)
    ,(SELECT WUSS_VALUE FROM WUSS WHERE WUSS_NAME='Hotelid')
    ) WHERE YPCF_CREATEDINHOTEL IS NULL;

COMMIT;
