📄 ad_element_trg.sql
字号:
CREATE OR REPLACE TRIGGER AD_Element_Trg
AFTER INSERT OR UPDATE
ON AD_Element
FOR EACH ROW
BEGIN
/*************************************************************************
* The contents of this file are subject to the Compiere License. You may
* obtain a copy of the License at http://www.compiere.org/CPL/ Software
* is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for details. Code: Compiere ERP+CPM Extensions
* Copyright (C) 1999-2001 Jorg Janke, Compiere, Inc. All Rights Reserved.
*************************************************************************
* Insert AD_Element Trigger
* for Translation
* Update AD_Element Trigger
* synchronize Column
* synchronize PrintInfo
* reset Translation flag
************************************************************************/
-- Insert AD_Element Trigger
IF INSERTING THEN
INSERT INTO AD_Element_Trl
(AD_Element_ID, AD_Language, AD_Client_ID, AD_Org_ID,
IsActive, Created, CreatedBy, Updated, UpdatedBy,
Name, PrintName, Description, Help,
PO_Name, PO_PrintName, PO_Description, PO_Help, IsTranslated)
SELECT :new.AD_Element_ID, AD_Language, :new.AD_Client_ID, :new.AD_Org_ID,
:new.IsActive, :new.Created, :new.CreatedBy, :new.Updated, :new.UpdatedBy,
:new.Name, :new.PrintName, :new.Description, :new.Help,
:new.PO_Name, :new.PO_PrintName, :new.PO_Description, :new.PO_Help, 'N'
FROM AD_Language
WHERE IsActive = 'Y' AND IsSystemLanguage = 'Y';
END IF; -- INSERTING
-- Update AD_Element Trigger
IF UPDATING THEN
-- synchronize Column
UPDATE AD_Column
SET Name = :new.Name,
ColumnName = :new.ColumnName,
Description = :new.Description,
Help = :new.Help
-- Updated = :new.Updated
WHERE AD_Element_ID = :new.AD_Element_ID;
/**
-- synchronize System PrintInfo or unchanged elements
IF (:old.PrintName <> :new.PrintName) THEN
UPDATE AD_PrintInfo pi
SET PrintName = :new.PrintName
WHERE EXISTS (SELECT * FROM AD_Column c
WHERE c.AD_Column_ID=pi.AD_Column_ID
AND c.AD_Element_ID=:new.AD_Element_ID)
AND (AD_Client_ID=0 OR PrintName=:old.PrintName);
END IF;
**/
-- reset Translation flag
IF (:old.Name <> :new.Name OR :old.PO_Name <> :new.PO_Name
OR :old.PrintName <> :new.PrintName OR :old.PO_PrintName <> :new.PO_PrintName
OR :old.Description <> :new.Description OR :old.PO_Description <> :new.PO_Description
OR :old.Help <> :new.Help OR :old.PO_Help <> :new.PO_Help) THEN
UPDATE AD_Element_Trl
SET IsTranslated='N'
WHERE AD_Element_ID = :new.AD_Element_ID;
END IF;
-- synchronize Process Fields
UPDATE AD_Process_Para
SET Name = :new.Name,
Description = :new.Description,
Help = :new.Help,
ColumnName = :new.ColumnName
-- Updated = :new.Updated
WHERE UPPER(ColumnName) = UPPER(:new.ColumnName)
AND IsCentrallyMaintained = 'Y';
END IF; -- UPDATING
END AD_Element_TI;
/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -