oracle行触发器的例题,关于触发器无法更新多行问题

单一品号当状态更新后可更新,多个品号(多行)无法更新,触发器如下:

create or replace trigger AA_PR_LINES_UPDATE_T1

after insert or update on "PO"."PO_REQUISITION_HEADERS_ALL"

referencing new as new

for each row

when (new.AUTHORIZATION_STATUS='APPROVED' and

new.requisition_header_id is not null)

begin

declare

p_header_id number;

p_line_id   number;

p_line_num  number;

ax          number;

bx          number;

p_item_id   NUMBER;

begin

select prl.item_id,prl.blanket_po_header_id,prl.blanket_po_line_num,prl.requisition_line_id

into p_item_id,ax,bx,p_line_id

from po_requisition_lines_all prl

where prl.requisition_header_id=:new.requisition_header_id;

select po_header_id,line_num into p_header_id,p_line_num

from (select ROW_NUMBER() OVER(ORDER BY pol.unit_price) rownumber

,poh.po_header_id,pol.line_num,s.vendor_name,ass.vendor_site_code,poh.vendor_id

,ass.vendor_site_id,poh.segment1,pol.unit_price,pol.attribute1,pol.attribute2

,pol.item_id

from po_headers_all poh,po_lines_all pol,ap_suppliers s,ap_supplier_sites_all ass

where poh.po_header_id = pol.po_header_id

and poh.type_lookup_code = 'BLANKET'

and pol.item_id =p_item_id

and poh.approved_flag = 'Y'

and NVL(pol.closed_code, 'OPEN') = 'OPEN'

and pol.creation_date || '-' || poh.vendor_id in (select max(pol.creation_date) || '-' || poh.vendor_id

from po_headers_all poh,

po_lines_all   pol

where poh.po_header_id = pol.po_header_id

and poh.type_lookup_code = 'BLANKET'

and pol.item_id = p_item_id

and NVL(pol.closed_code,'OPEN') = 'OPEN'

and nvl(pol.cancel_flag,'N') = 'N'

and poh.approved_flag = 'Y'

group by poh.vendor_id)

and nvl(pol.cancel_flag, 'N') = 'N'

and poh.vendor_id=s.vendor_id

and s.vendor_id=ass.vendor_id)

where 1 = 1

and rownumber = 1;

if ax<>p_header_id /*and bx<>p_line_num*/ then

update PO_REQUISITION_LINES_ALL prl

set prl.blanket_po_header_id=p_header_id

,prl.blanket_po_line_num=p_line_num

where prl.requisition_header_id=:new.requisition_header_id

and prl.item_id=p_item_id

and prl.requisition_line_id=p_line_id;

commit;

end if;

exception

when others then null;

end;

end;

请高手帮忙看下哪里写错了。在线等

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值