121: x_return_status := FND_API.G_RET_STS_SUCCESS;
122: -- API body
123:
124: select milcs_id, start_date_time into l_milcs_id, l_start_date_time
125: from jtf_ih_media_item_lc_segs
126: where media_id = p_media_item_id and milcs_type_id = p_milcs_type_id
127: and end_date_time is null;
128:
129: if sql%notfound then raise NO_DATA_FOUND;
221:
222: x_return_status := FND_API.G_RET_STS_SUCCESS;
223: x_can_close_media_item := 1; -- initialize to cannot close.
224:
225: select max(c.end_date_time) into l_end_date_time from jtf_ih_media_item_lc_segs c
226: where c.media_id = p_media_item_id and c.milcs_type_id = IH_MILCS_TYPE_WITH_AGENT;
227:
228: if l_end_date_time is null then raise NO_DATA_FOUND;
229: end if;
227:
228: if l_end_date_time is null then raise NO_DATA_FOUND;
229: end if;
230:
231: select count(*) into l_nwa_count from jtf_ih_media_item_lc_segs c
232: where c.media_id = p_media_item_id and c.milcs_type_id = IH_MILCS_TYPE_WITH_AGENT
233: and c.end_date_time IS NULL ;
234:
235: if ( l_nwa_count > 0 ) then raise NO_DATA_FOUND ;
234:
235: if ( l_nwa_count > 0 ) then raise NO_DATA_FOUND ;
236: end if;
237:
238: select max(c.start_date_time) into l_start_date_time from jtf_ih_media_item_lc_segs c
239: where c.media_id = p_media_item_id and c.milcs_type_id = IH_MILCS_TYPE_WITH_AGENT;
240: l_in_queue_start_date_time := null;
241: select max(c.start_date_time) into l_in_queue_start_date_time from jtf_ih_media_item_lc_segs c
242: where c.media_id = p_media_item_id and c.milcs_type_id = IH_MILCS_TYPE_IN_QUEUE;
237:
238: select max(c.start_date_time) into l_start_date_time from jtf_ih_media_item_lc_segs c
239: where c.media_id = p_media_item_id and c.milcs_type_id = IH_MILCS_TYPE_WITH_AGENT;
240: l_in_queue_start_date_time := null;
241: select max(c.start_date_time) into l_in_queue_start_date_time from jtf_ih_media_item_lc_segs c
242: where c.media_id = p_media_item_id and c.milcs_type_id = IH_MILCS_TYPE_IN_QUEUE;
243:
244: if (l_in_queue_start_date_time is not null) and
245: (l_start_date_time is not null) and