PL/SQL出错:ORA-000918:column ambiguously definedbegin
--在购数量
select sum(nvl(plla.quantity, 0) - nvl(plla.quantity_received, 0))
into purchase_quantity
from PO_HEADERS_ALL pha,
PO_LINES_ALL pla,
po_line_locations_all plla
where pla.item_id = rec_cj.inventory_item_id
and pla.closed_code = 'OPEN'
and pla.po_header_id = pha.po_header_id
and to_date(end_date, 'yyyy-mm-dd hh24:mi:ss') =
to_date(end_date, 'yyyy-mm-dd hh24:mi:ss')
and pha.authorization_status = 'APPROVED'
and pla.po_line_id = plla.po_line_id
and plla.quantity > plla.quantity_received;
exception
when others then
purchase_quantity := 0;
end;不明白,同样的两行,为什么上一个end_date就没有问题,下面这行,怎么都不对,实在看不出有什么错。
--在购数量
select sum(nvl(plla.quantity, 0) - nvl(plla.quantity_received, 0))
into purchase_quantity
from PO_HEADERS_ALL pha,
PO_LINES_ALL pla,
po_line_locations_all plla
where pla.item_id = rec_cj.inventory_item_id
and pla.closed_code = 'OPEN'
and pla.po_header_id = pha.po_header_id
and to_date(end_date, 'yyyy-mm-dd hh24:mi:ss') =
to_date(end_date, 'yyyy-mm-dd hh24:mi:ss')
and pha.authorization_status = 'APPROVED'
and pla.po_line_id = plla.po_line_id
and plla.quantity > plla.quantity_received;
exception
when others then
purchase_quantity := 0;
end;不明白,同样的两行,为什么上一个end_date就没有问题,下面这行,怎么都不对,实在看不出有什么错。
没有指定谁的end_date列吧
AND TO_DATE(END_DATE, 'yyyy-mm-dd hh24:mi:ss') =
TO_DATE(END_DATE, 'yyyy-mm-dd hh24:mi:ss')
and to_date(end_date, 'yyyy-mm-dd hh24:mi:ss') =
to_date(end_date, 'yyyy-mm-dd hh24:mi:ss')
这是干吗用的?
你两个end_date是不是应该加表别名啊.