⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c_elementvalue_trg.sql

📁 Java写的ERP系统
💻 SQL
字号:
CREATE OR REPLACE TRIGGER C_ElementValue_Trg
AFTER INSERT OR UPDATE OF Name 
	ON C_ElementValue
FOR EACH ROW
/*************************************************************************
 * 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-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved.
 *************************************************************************
 * $Id: C_ElementValue_Trg.sql,v 1.4 2003/02/19 06:49:07 jjanke Exp $
 ***
 * Title:	Element Value
 * Description:
 *	- Update Translation
 *	- Add Tree Node
 ************************************************************************/
DECLARE
	xTree_ID	NUMBER;
	xParent_ID	NUMBER;
	NextNo		NUMBER;
BEGIN

	--	Insert C_ElementValue Trigger 
	--		for Translation 
	--		and TreeNode
	IF INSERTING THEN
		--  Create Translation Row
		INSERT INTO C_ElementValue_Trl
			(C_ElementValue_ID, AD_Language, AD_Client_ID, AD_Org_ID,
			IsActive, Created, CreatedBy, Updated, UpdatedBy,
			Name, IsTranslated)
		SELECT :new.C_ElementValue_ID, AD_Language, :new.AD_Client_ID, :new.AD_Org_ID,
			:new.IsActive, :new.Created, :new.CreatedBy, :new.Updated, :new.UpdatedBy,
			:new.Name, 'N'
		FROM	AD_Language
		WHERE	IsActive = 'Y' AND IsSystemLanguage = 'Y';

		--  Create TreeNode --
		--  get AD_Tree_ID + ParentID
		SELECT	e.AD_Tree_ID, n.Node_ID INTO xTree_ID, xParent_ID
		FROM	C_Element e, AD_TreeNode n
		WHERE	e.AD_Tree_ID=n.AD_Tree_ID
			AND n.Parent_ID IS NULL
			AND e.C_Element_ID=:new.C_Element_ID;
	
		--  DBMS_OUTPUT.PUT_LINE('Tree='||xTree_ID||'  Node='||:new.C_ElementValue_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.C_ElementValue_ID, 
			xParent_ID, DECODE(:new.IsSummary, 'Y', 100, 999));		-- Summary Nodes first
	END IF;	--	Inserting

	--	C_ElementValue update trigger
	--		synchronize name,... 
	IF UPDATING THEN
		UPDATE	C_ElementValue_Trl
		  SET	IsTranslated = 'N',
				Updated=SysDate
		WHERE	C_ElementValue_ID = :new.C_ElementValue_ID;
		 
		 --   Update Valid Combination Description
		 UPDATE	   C_ValidCombination
		   SET	   Updated = SysDate
		 WHERE	   Account_ID = :new.C_ElementValue_ID
		   OR	   User1_ID = :new.C_ElementValue_ID OR User2_ID = :new.C_ElementValue_ID;
	END IF;	--	Updating

EXCEPTION
	WHEN NO_DATA_FOUND THEN
		RAISE_APPLICATION_ERROR (-20001, 'C_ElementValue InsertTrigger Error: No ClientInfo or parent TreeNode');

END C_ElementValue_TI;
/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -