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

📄 ad_client_trg.sql

📁 Java写的ERP系统
💻 SQL
字号:
CREATE OR REPLACE TRIGGER AD_Client_Trg
AFTER INSERT
	ON AD_Client
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_Client_Trg.sql,v 1.2 2002/05/29 04:25:38 jjanke Exp $
 ***
 * Title:	AD_Client
 * Description:
 *		Add DocumentNo Sequences for the new Client
 ************************************************************************/
	--	TableNames to be added
 	CURSOR CUR_DSequence IS
		SELECT 	TableName
		FROM	AD_Table t
		WHERE	IsActive='Y'
		  -- Get all Tables with DocumentNo or Value
		  AND AD_Table_ID IN 
			(SELECT AD_Table_ID FROM AD_Column 
			WHERE ColumnName = 'DocumentNo' OR ColumnName = 'Value')
		  AND 'DocumentNo_' || TableName NOT IN
		  	(SELECT Name FROM AD_Sequence s
			WHERE s.AD_Client_ID = :new.AD_Client_ID);
	--
	v_NextNo					NUMBER;
BEGIN
	--	See also: AD_Sequence_Check
	FOR s IN CUR_DSequence LOOP
	--	DBMS_OUTPUT.PUT_LINE(' ' || :new.AD_Client_ID || ' - ' || s.TableName);
		--
		AD_Sequence_Next ('AD_Sequence', :new.AD_Client_ID, v_NextNo);
		INSERT INTO AD_Sequence
			(AD_Sequence_ID,
			AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
			Name, Description, 
			VFormat, IsAutoSequence,
			IncrementNo, StartNo, CurrentNext, CurrentNextSys,
			IsAudited, IsTableID, Prefix, Suffix, StartNewYear)
		VALUES
			(v_NextNo,
			:new.AD_Client_ID, 0, 'Y', SysDate, 0, SysDate, 0,
			'DocumentNo_' || s.TableName, 'DocumentNo/Value for Table ' || s.TableName,
		 	NULL, 'Y',
			1, 10000000, 10000000, 10000000,
			'N', 'N', NULL, NULL, 'N');
	END LOOP;	--	Sequences
END AD_Client_Trg;
/

⌨️ 快捷键说明

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