The following lines contain the word 'select', 'insert', 'update' or 'delete':
INSERT INTO PO_SESSION_GT
( key
)
SELECT l_procedure_id
FROM DUAL
WHERE
EXISTS (select null from po_requisition_headers h
WHERE h.requisition_header_id = p_req_header_id(i)
AND (h.authorization_status is NULL
OR h.authorization_status NOT IN ('PRE-APPROVED', 'IN PROCESS'))
AND (h.cancel_flag is null or h.cancel_flag <> 'Y')
AND (h.closed_code is NULL or h.closed_code NOT IN ('FINALLY CLOSED')))
AND (p_req_line_id(i) IS NULL
OR EXISTS (SELECT null from po_requisition_lines l
WHERE l.requisition_header_id = p_req_header_id(i)
and l.requisition_line_id = p_req_line_id(i)
AND (l.cancel_flag is null or l.cancel_flag <> 'Y')
AND (l.closed_code is NULL or l.closed_code NOT IN ('FINALLY CLOSED'))
AND nvl(l.modified_by_agent_flag, 'N') = 'N'))
;
DELETE FROM po_session_gt
WHERE key = l_procedure_id;
INSERT INTO PO_SESSION_GT
( key
)
SELECT l_procedure_id
FROM DUAL
WHERE
EXISTS (select null from po_requisition_headers h
WHERE h.requisition_header_id = p_req_header_id(i)
AND (h.authorization_status is NULL
OR h.authorization_status NOT IN ('APPROVED'))
AND (h.closed_code is NULL or h.closed_code IN ('OPEN', 'CLOSED')))
AND (p_req_line_id(i) IS NULL
OR EXISTS (SELECT null from po_requisition_lines l
WHERE l.requisition_header_id = p_req_header_id(i)
and l.requisition_line_id = p_req_line_id(i)
AND (l.closed_code is NULL or l.closed_code IN ('OPEN', 'CLOSED'))))
;
DELETE FROM po_session_gt
WHERE key = l_procedure_id;
INSERT INTO PO_SESSION_GT
( key
)
SELECT l_procedure_id
FROM DUAL
WHERE
EXISTS (select null from po_requisition_headers h
WHERE h.requisition_header_id = p_req_header_id(i)
AND (h.closed_code is NULL or h.closed_code IN ('OPEN', 'CLOSED')))
AND (p_req_line_id(i) IS NULL
OR EXISTS (SELECT null from po_requisition_lines l
WHERE l.requisition_header_id = p_req_header_id(i)
AND l.requisition_line_id = p_req_line_id(i)
AND (l.closed_code is NULL or l.closed_code IN ('OPEN', 'CLOSED'))))
;
DELETE FROM po_session_gt
WHERE key = l_procedure_id;
delete from po_headers_gt;
INSERT
INTO po_headers_gt
( AGENT_ID, TYPE_LOOKUP_CODE, LAST_UPDATE_DATE, LAST_UPDATED_BY,
SEGMENT1, SUMMARY_FLAG, ENABLED_FLAG,
authorization_status, closed_code,
cancel_flag, PO_HEADER_ID)
SELECT
-1, TYPE_LOOKUP_CODE, LAST_UPDATE_DATE, LAST_UPDATED_BY,
SEGMENT1, SUMMARY_FLAG, ENABLED_FLAG,
NVL(authorization_status, 'INCOMPLETE'), nvl(closed_code, 'OPEN'),
NVL(cancel_flag, 'N'), l_sequence(i)
FROM po_requisition_headers h
WHERE h.requisition_header_id = p_req_header_id(i)
;
UPDATE po_headers_gt gt
SET (closed_code, cancel_flag)
=
(SELECT nvl(closed_code, 'OPEN'), NVL(cancel_flag, 'N')
FROM po_requisition_lines s
WHERE s.requisition_line_id = p_req_line_id(i))
WHERE p_req_line_id(i) is not null and gt.po_header_id = l_sequence(i)
;
SELECT
authorization_status, closed_code,
cancel_flag
BULK COLLECT INTO
x_req_status_rec.authorization_status, x_req_status_rec.closed_code,
x_req_status_rec.cancel_flag
FROM po_headers_gt
ORDER BY PO_HEADER_ID;
IF INSTR(p_mode, G_CHECK_UPDATEABLE) > 0 THEN
check_updatable (
p_count => l_count,
p_req_header_id => p_req_header_id,
p_req_line_id => p_req_line_id,
p_req_distribution_id => p_req_distribution_id,
p_lock_flag => p_lock_flag,
x_req_status_rec => x_req_status_rec,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data);
END IF; --END of IF INSTR(p_mode, G_CHECK_UPDATEABLE) > 0