📄 ad_org_trg.sql
字号:
CREATE OR REPLACE TRIGGER AD_Org_Trg
AFTER INSERT
ON AD_Org
FOR EACH ROW
DECLARE
/*************************************************************************
* The contents of this file are subject to the Compiere License. You may
* obtain a copy of the License at http://www.compiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Compiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: AD_Org_Trg.sql,v 1.5 2002/12/02 03:37:20 jjanke Exp $
***
* Title: Insert Access to all Roles of Client
* Description:
* Add Org to
* Org Access
* Tree
* OrgInfo
************************************************************************/
xTree_ID NUMBER;
xParent_ID NUMBER;
BEGIN
IF (INSERTING) THEN
-- Add to all roles of the client
INSERT INTO AD_Role_OrgAccess (AD_Role_ID,
AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy)
SELECT AD_Role_ID,
:new.AD_Client_ID, :new.AD_Org_ID, 'Y', SysDate, :new.CreatedBy, SysDate, :new.CreatedBy
FROM AD_Role
WHERE AD_Client_ID = :new.AD_Client_ID;
-- Create TreeNode --
-- get AD_Tree_ID + ParentID
SELECT c.AD_Tree_Org_ID, n.Node_ID INTO xTree_ID, xParent_ID
FROM AD_ClientInfo c, AD_TreeNode n
WHERE c.AD_Tree_Org_ID=n.AD_Tree_ID
AND n.Parent_ID IS NULL
AND c.AD_Client_ID=:new.AD_Client_ID;
-- DBMS_OUTPUT.PUT_LINE('Tree='||xTree_ID||' Node='||:new.AD_Org_ID||' Parent='||xParent_ID);
-- Insert into TreeNode
INSERT INTO AD_TreeNode
(AD_Client_ID, AD_Org_ID,
IsActive, Created, CreatedBy, Updated, UpdatedBy,
AD_Tree_ID, Node_ID,
Parent_ID, SeqNo)
VALUES
(:new.AD_Client_ID, :new.AD_Org_ID,
:new.IsActive, :new.Created, :new.CreatedBy, :new.Updated, :new.UpdatedBy,
xTree_ID, :new.AD_Org_ID,
xParent_ID, DECODE(:new.IsSummary, 'Y', 100, 999)); -- Summary Nodes first
-- Org Info
INSERT INTO AD_OrgInfo
(AD_Org_ID, AD_Client_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
C_Location_ID, Duns, TaxID, PA_Goal_ID)
VALUES
(:new.AD_Org_ID, :new.AD_Client_ID, 'Y', SysDate, :new.CreatedBy, SysDate, :new.CreatedBy,
NULL, '?', '?', NULL);
END IF; -- Inserting
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR (-20001, 'AD_Org InsertTrigger Error: No ClientInfo or parent TreeNode');
END AD_Org_Trg;
/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -