SELECT pol.po_header_id,pol.line_num,pol.PO_LINE_ID,
rownum sl_no, prl.po_release_id,
ol.item_id item_code, pol.attribute11,
pol.item_description,pol.UNIT_MEAS_LOOKUP_CODE uom,
pll.quantity,pll.price_override, pll.need_by_date
FROM po_lines_all pol,
po_headers_all poh,
po_releases_all prl,
po_line_locations_all pll
WHERE poh.po_header_id = pol.po_header_id
AND pol.po_line_id =pll.po_line_id
AND pll.po_RELEASE_ID = prl.po_release_id(+)
AND poh.TYPE_LOOKUP_CODE = 'STANDARD'
and NVL(pll.cancel_flag,'N')='N'
and NVL(pll.closed_code,'OPEN') not in ('FINALLY CLOSED','CLOSED FOR RECEIVING','CLOSED')
UNION
SELECT pol.po_header_id,pol.line_num,pol.PO_LINE_ID,
rownum sl_no, null po_release_id, --prl.po_release_id,
pol.item_id item_code, pol.attribute11,
pol.item_description,pol.UNIT_MEAS_LOOKUP_CODE uom,
NVL(pol.quantity,0),NVL(pol.unit_price,0),
NULL need_by_date
FROM po_lines_all pol,
po_headers_all poh
WHERE poh.po_header_id = pol.po_header_id
--AND pol.po_line_id = pll.po_line_id
--AND pll.po_RELEASE_ID = prl.po_release_id(+)
AND poh.TYPE_LOOKUP_CODE = 'BLANKET'
AND :p_from_rel_num IS NULL
and NVL(pol.cancel_flag,'N')='N'
and NVL(pol.closed_code,'OPEN') not in ('FINALLY CLOSED','CLOSED FOR RECEIVING','CLOSED')
UNION
SELECT pol.po_header_id,pol.line_num,pol.PO_LINE_ID,
rownum sl_no, null po_release_id, --prl.po_release_id,
pol.item_id item_code, pol.attribute11,
pol.item_description,pol.UNIT_MEAS_LOOKUP_CODE uom,
pll.quantity, pll.price_override, pll.need_by_date
FROM po_lines_all pol,
po_headers_all poh,
po_releases_all prl,
po_line_locations_all pll
WHERE poh.po_header_id = pol.po_header_id
AND pol.po_line_id = pll.po_line_id
AND pll.po_RELEASE_ID = prl.po_release_id(+)
AND poh.TYPE_LOOKUP_CODE = 'BLANKET'
AND :p_from_rel_num IS NULL
AND pol.quantity IS NOT NULL
and NVL(pll.cancel_flag,'N')='N'
and NVL(pll.closed_code,'OPEN') not in ('FINALLY CLOSED','CLOSED FOR RECEIVING','CLOSED')
ORDER BY po_header_id,po_line_id
thanks, I wonder ':p_from_rel_num IS NULL' --> what clolumn?
ReplyDelete