2866: --
2867: cursor csr_offer_history_details(p_offer_id number) is
2868: select offer_status
2869: ,change_reason
2870: from irc_offer_status_history HISTORY
2871: where HISTORY.offer_id = p_offer_id
2872: and not EXISTS (SELECT 1
2873: FROM irc_offer_status_history iosh1
2874: WHERE iosh1.offer_id = HISTORY.offer_id
2869: ,change_reason
2870: from irc_offer_status_history HISTORY
2871: where HISTORY.offer_id = p_offer_id
2872: and not EXISTS (SELECT 1
2873: FROM irc_offer_status_history iosh1
2874: WHERE iosh1.offer_id = HISTORY.offer_id
2875: AND iosh1.status_change_date > HISTORY.status_change_date
2876: )
2877: AND HISTORY.offer_status_history_id =
2875: AND iosh1.status_change_date > HISTORY.status_change_date
2876: )
2877: AND HISTORY.offer_status_history_id =
2878: (SELECT MAX(iosh2.offer_status_history_id)
2879: FROM irc_offer_status_history iosh2
2880: WHERE iosh2.offer_id = HISTORY.offer_id
2881: AND iosh2.status_change_date = HISTORY.status_change_date
2882: );
2883: --
2882: );
2883: --
2884: cursor csr_offer_status_before_hold is
2885: SELECT ios1.offer_status
2886: FROM irc_offer_status_history ios1
2887: WHERE EXISTS ( SELECT 1
2888: FROM irc_offer_status_history iosh1
2889: WHERE iosh1.offer_id = l_offer_id
2890: AND iosh1.status_change_date > ios1.status_change_date
2884: cursor csr_offer_status_before_hold is
2885: SELECT ios1.offer_status
2886: FROM irc_offer_status_history ios1
2887: WHERE EXISTS ( SELECT 1
2888: FROM irc_offer_status_history iosh1
2889: WHERE iosh1.offer_id = l_offer_id
2890: AND iosh1.status_change_date > ios1.status_change_date
2891: )
2892: AND ios1.offer_status_history_id = (SELECT MAX(iosh2.offer_status_history_id)
2889: WHERE iosh1.offer_id = l_offer_id
2890: AND iosh1.status_change_date > ios1.status_change_date
2891: )
2892: AND ios1.offer_status_history_id = (SELECT MAX(iosh2.offer_status_history_id)
2893: FROM irc_offer_status_history iosh2
2894: WHERE iosh2.offer_id = l_offer_id
2895: AND iosh2.status_change_date = ios1.status_change_date
2896: )
2897: AND 1 =
2895: AND iosh2.status_change_date = ios1.status_change_date
2896: )
2897: AND 1 =
2898: (SELECT COUNT(*)
2899: FROM irc_offer_status_history ios3
2900: WHERE ios3.offer_id = l_offer_id
2901: AND ios3.status_change_date > ios1.status_change_date
2902: );
2903: --