给定下面的参数,我想从一个表中获取数据到另一个表..
所以我有 4 张桌子,它们是
M_InternalRequester, M_InternalRequesterLine, M_Inventory, M_InventoryLine
M_InternalRequester
-----------------------
m_internalrequester_id
-----------------------
1001
M_InternalRequesterLine
------------------------------------------------------------------------------
m_internalrequesterline_id || m_internalrequester_id || m_product_id || qty ||
------------------------------------------------------------------------------
3001 || 1001 || 21001 || 3 ||
3002 || 1001 || 21002 || 4 ||
M_Inventory
----------------------------------------------------------------------
m_inventory_id || description || m_internalrequester_id ||
----------------------------------------------------------------------
8001 || Referred from Internal || 1001 ||
M_InventoryLine
--------------------------------------------------------------
m_inventoryline_id || m_inventory_id || m_product_id || qty ||
--------------------------------------------------------------
??????????? || 8001 || ??????????? || ?? ||
??????????? || 8001 || ??????????? || ?? ||
我有以前记录在M_Internal Requester
和M_InternalRequesterLine
我想根据表中给出的参数从M_InternalRequesterLine
to获取数据M_InventoryLine
m_internalrequester_id
M_Inventory
我做了一个这样的触发器
create or replace trigger TG_AI_M_INVENTORYSN
before update on m_inventory
for each row
declare
internalrequester_id number;
invline_id number;
CURSOR c1 is
select
M_PRODUCT_ID, QTY
from m_internalrequesterline
where m_internalrequester_id=:new.m_internalrequester_id;
BEGIN
if inserting then
SELECT M_INTERNALREQUESTER_ID INTO INTERNALREQUESTER_ID FROM M_INTERNALREQUESTER WHERE
m_internalrequester_ID = :new.m_internalrequester_id;
FOR insertline in C1
LOOP
select currentnext into invline_id from AD_Sequence WHERE
name = 'M_Inventoryline';
INSERT INTO M_INVENTORYLINE
(m_inventoryline_id, m_product_id, qty
)
VALUES
(invline_id, insertline.m_product_id, insertline.qty);
update AD_Sequence set currentnext=invline_id+1 where name = 'M_Inventoryline';
END LOOP;
END IF;
end;
它是创建的,但是当我执行它时它不起作用。有什么问题,我该如何解决?