0
參數獲取數據,我想從一個表到另一個,下面給出的參數來獲取數據..從一個表到另一個
所以我有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_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;
它的建立,但是當我執行它不會工作參數m_internalrequester_id
從M_InternalRequesterLine
獲取數據到M_InventoryLine
。有什麼問題,我該如何解決?