ad_pinstance_trg.sql

来自「Java写的ERP系统」· SQL 代码 · 共 34 行

SQL
34
字号
CREATE OR REPLACE TRIGGER AD_PInstance_Trg
AFTER UPDATE OF IsProcessing
	ON AD_PInstance
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_PInstance_Trg.sql,v 1.1 2002/01/20 20:53:58 jjanke Exp $
 ***
 * Title:	Update Process Statistics
 * Description:
 ************************************************************************/
 	v_Seconds		NUMBER;
BEGIN
	IF (:old.IsProcessing='Y' AND :new.IsProcessing='N') THEN
		--	Calculate Seconds
		v_Seconds := (:new.Updated-:new.Created) * 86400;	-- 24*60*60
		IF (v_Seconds = 0) THEN
			v_Seconds := 1;
	   	END IF;

		UPDATE AD_Process
			SET Statistic_Count = NVL(Statistic_Count, 0) + 1, 
				Statistic_Seconds = NVL(Statistic_Seconds,0) + v_Seconds
		WHERE AD_Process_ID = :new.AD_Process_ID;
	END IF;
END AD_PInstance_Trg;
/

⌨️ 快捷键说明

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