IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management - Foreign keys management

This commit is contained in:
Elaine Tan 2013-07-19 18:42:26 +08:00
parent 1572784afe
commit bc37aab2e4
6 changed files with 1065 additions and 7 deletions

View File

@ -0,0 +1,257 @@
-- Jul 17, 2013 6:31:01 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=30,Updated=TO_DATE('2013-07-17 18:31:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200067
;
-- Jul 17, 2013 6:32:15 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,Name,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Classname,Value,AD_Client_ID) VALUES ('N',200058,'N','N','a3b56b92-5704-48f7-b05a-c82adc965c1e','4','N','N',0,0,'Y','D','Create Foreign Key',0,TO_DATE('2013-07-17 18:32:14','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-17 18:32:14','YYYY-MM-DD HH24:MI:SS'),'Y',100,'org.compiere.process.CreateForeignKey','CreateForeignKey',0)
;
-- Jul 17, 2013 6:32:16 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Trl_UU ) SELECT l.AD_Language,t.AD_Process_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=200058 AND NOT EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_ID=t.AD_Process_ID)
;
-- Jul 17, 2013 6:32:54 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,AD_Val_Rule_ID,IsMandatory,AD_Reference_Value_ID,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID) VALUES ('N',126,200069,'79638995-cc19-4b2d-99f9-3280ab62ae11','The Database Table provides the information of the table definition',200058,30,200047,'N',53290,'D','Table','AD_Table_ID','Database Table information',0,'Y',10,'Y',100,TO_DATE('2013-07-17 18:32:53','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-17 18:32:53','YYYY-MM-DD HH24:MI:SS'),0,'N',0)
;
-- Jul 17, 2013 6:32:54 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200069 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID)
;
-- Jul 17, 2013 6:33:35 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,AD_Val_Rule_ID,IsMandatory,AD_Reference_Value_ID,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID) VALUES ('N',104,200070,'e16a1a3c-31e3-4b7a-af4d-05420e7b17bb','Link to the database column of the table',200058,30,100,'N',3,'D','Column','AD_Column_ID','Column in the table',0,'Y',20,'Y',100,TO_DATE('2013-07-17 18:33:34','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-17 18:33:34','YYYY-MM-DD HH24:MI:SS'),0,'N',0)
;
-- Jul 17, 2013 6:33:35 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200070 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID)
;
-- Jul 17, 2013 6:34:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu (AD_Menu_ID,IsSummary,IsSOTrx,IsReadOnly,AD_Process_ID,EntityType,IsCentrallyMaintained,Name,AD_Menu_UU,Action,IsActive,CreatedBy,Updated,AD_Org_ID,Created,UpdatedBy,AD_Client_ID) VALUES (200065,'N','N','N',200058,'D','Y','Create Foreign Key','54351c18-3276-4429-b9c0-1d072b296e91','P','Y',100,TO_DATE('2013-07-17 18:34:30','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2013-07-17 18:34:30','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- Jul 17, 2013 6:34:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Menu_Trl_UU ) SELECT l.AD_Language,t.AD_Menu_ID, t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=200065 AND NOT EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Menu_ID=t.AD_Menu_ID)
;
-- Jul 17, 2013 6:34:32 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_TreeNodeMM (AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, AD_Tree_ID, Node_ID, Parent_ID, SeqNo, AD_TreeNodeMM_UU) SELECT t.AD_Client_ID, 0, 'Y', SysDate, 100, SysDate, 100,t.AD_Tree_ID, 200065, 0, 999, Generate_UUID() FROM AD_Tree t WHERE t.AD_Client_ID=0 AND t.IsActive='Y' AND t.IsAllNodes='Y' AND t.TreeType='MM' AND NOT EXISTS (SELECT * FROM AD_TreeNodeMM e WHERE e.AD_Tree_ID=t.AD_Tree_ID AND Node_ID=200065)
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=0, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53203
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=1, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=586
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=2, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=138
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=3, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=139
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=4, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=200065
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=5, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=200063
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=6, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=249
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=7, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=141
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=8, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=300
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=9, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=589
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=10, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=200000
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=11, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=295
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=12, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=216
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=13, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=140
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=14, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=142
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=15, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53012
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=16, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=143
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=17, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=201
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=18, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=176
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=19, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53086
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=20, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=239
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=21, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=517
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=22, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=499
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=23, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53089
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=24, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53090
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=25, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=200038
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=26, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=50001
;
-- Jul 17, 2013 7:12:19 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=19,Updated=TO_DATE('2013-07-17 19:12:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200067
;
-- Jul 17, 2013 7:12:39 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=19,Updated=TO_DATE('2013-07-17 19:12:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200069
;
-- Jul 17, 2013 7:12:49 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=19,Updated=TO_DATE('2013-07-17 19:12:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200070
;
-- Jul 17, 2013 7:14:14 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Processed table: {0}, Processed foreign key: {1}, Error: {2}',200205,'D','2ea056aa-31ad-479b-8649-a9c7c202cbcb','CreateForeignKeyProcessResult','Y',TO_DATE('2013-07-17 19:14:13','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-17 19:14:13','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 17, 2013 7:14:14 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200205 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 17, 2013 7:14:51 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Process table: ',200206,'D','e2a802b1-2a0d-4f80-859a-1c2ef7fd92c2','CreateForeignKeyProcessTable','Y',TO_DATE('2013-07-17 19:14:47','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-17 19:14:47','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 17, 2013 7:14:51 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200206 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 18, 2013 6:00:55 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_DATE('2013-07-18 18:00:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200069
;
-- Jul 19, 2013 6:02:32 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Process column: ',200209,'D','28924812-7226-4107-8c36-8447763bc7cd','CreateForeignKeyProcessColumn','Y',TO_DATE('2013-07-19 18:02:30','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-19 18:02:30','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 19, 2013 6:02:32 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200209 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 19, 2013 6:05:21 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Foreign key already exists: ',200210,'D','fc625fe7-0dcb-455c-b4ba-7b5cc7dd2939','CreateForeignKeyProcessExists','Y',TO_DATE('2013-07-19 18:05:20','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-07-19 18:05:20','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 19, 2013 6:05:21 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200210 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 19, 2013 6:05:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Message SET MsgText='Foreign key already exists: ',Updated=TO_DATE('2013-07-19 18:05:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200210
;
-- Jul 19, 2013 6:05:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Message_Trl SET MsgText='Foreign key already exists: ',Updated=TO_DATE('2013-07-19 18:05:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200210 AND AD_Language='es_CO'
;
SELECT register_migration_script('201307191811_IDEMPIERE-1132.sql') FROM dual
;

View File

@ -0,0 +1,257 @@
-- Jul 17, 2013 6:31:01 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2013-07-17 18:31:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200067
;
-- Jul 17, 2013 6:32:15 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,EntityType,Name,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Classname,Value,AD_Client_ID) VALUES ('N',200058,'N','N','a3b56b92-5704-48f7-b05a-c82adc965c1e','4','N','N',0,0,'Y','D','Create Foreign Key',0,TO_TIMESTAMP('2013-07-17 18:32:14','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-17 18:32:14','YYYY-MM-DD HH24:MI:SS'),'Y',100,'org.compiere.process.CreateForeignKey','CreateForeignKey',0)
;
-- Jul 17, 2013 6:32:16 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Trl (AD_Language,AD_Process_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Trl_UU ) SELECT l.AD_Language,t.AD_Process_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_ID=200058 AND NOT EXISTS (SELECT * FROM AD_Process_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_ID=t.AD_Process_ID)
;
-- Jul 17, 2013 6:32:54 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,AD_Val_Rule_ID,IsMandatory,AD_Reference_Value_ID,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID) VALUES ('N',126,200069,'79638995-cc19-4b2d-99f9-3280ab62ae11','The Database Table provides the information of the table definition',200058,30,200047,'N',53290,'D','Table','AD_Table_ID','Database Table information',0,'Y',10,'Y',100,TO_TIMESTAMP('2013-07-17 18:32:53','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-17 18:32:53','YYYY-MM-DD HH24:MI:SS'),0,'N',0)
;
-- Jul 17, 2013 6:32:54 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200069 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID)
;
-- Jul 17, 2013 6:33:35 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para (IsRange,AD_Element_ID,AD_Process_Para_ID,AD_Process_Para_UU,Help,AD_Process_ID,AD_Reference_ID,AD_Val_Rule_ID,IsMandatory,AD_Reference_Value_ID,EntityType,Name,ColumnName,Description,FieldLength,IsCentrallyMaintained,SeqNo,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID) VALUES ('N',104,200070,'e16a1a3c-31e3-4b7a-af4d-05420e7b17bb','Link to the database column of the table',200058,30,100,'N',3,'D','Column','AD_Column_ID','Column in the table',0,'Y',20,'Y',100,TO_TIMESTAMP('2013-07-17 18:33:34','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-17 18:33:34','YYYY-MM-DD HH24:MI:SS'),0,'N',0)
;
-- Jul 17, 2013 6:33:35 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Process_Para_Trl (AD_Language,AD_Process_Para_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Process_Para_Trl_UU ) SELECT l.AD_Language,t.AD_Process_Para_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Process_Para t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Process_Para_ID=200070 AND NOT EXISTS (SELECT * FROM AD_Process_Para_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Process_Para_ID=t.AD_Process_Para_ID)
;
-- Jul 17, 2013 6:34:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu (AD_Menu_ID,IsSummary,IsSOTrx,IsReadOnly,AD_Process_ID,EntityType,IsCentrallyMaintained,Name,AD_Menu_UU,"action",IsActive,CreatedBy,Updated,AD_Org_ID,Created,UpdatedBy,AD_Client_ID) VALUES (200065,'N','N','N',200058,'D','Y','Create Foreign Key','54351c18-3276-4429-b9c0-1d072b296e91','P','Y',100,TO_TIMESTAMP('2013-07-17 18:34:30','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2013-07-17 18:34:30','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- Jul 17, 2013 6:34:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Menu_Trl_UU ) SELECT l.AD_Language,t.AD_Menu_ID, t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=200065 AND NOT EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Menu_ID=t.AD_Menu_ID)
;
-- Jul 17, 2013 6:34:32 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_TreeNodeMM (AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, AD_Tree_ID, Node_ID, Parent_ID, SeqNo, AD_TreeNodeMM_UU) SELECT t.AD_Client_ID, 0, 'Y', statement_timestamp(), 100, statement_timestamp(), 100,t.AD_Tree_ID, 200065, 0, 999, Generate_UUID() FROM AD_Tree t WHERE t.AD_Client_ID=0 AND t.IsActive='Y' AND t.IsAllNodes='Y' AND t.TreeType='MM' AND NOT EXISTS (SELECT * FROM AD_TreeNodeMM e WHERE e.AD_Tree_ID=t.AD_Tree_ID AND Node_ID=200065)
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=0, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53203
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=1, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=586
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=2, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=138
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=3, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=139
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=4, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=200065
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=5, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=200063
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=6, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=249
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=7, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=141
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=8, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=300
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=9, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=589
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=10, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=200000
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=11, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=295
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=12, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=216
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=13, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=140
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=14, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=142
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=15, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53012
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=16, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=143
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=17, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=201
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=18, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=176
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=19, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53086
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=20, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=239
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=21, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=517
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=22, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=499
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=23, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53089
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=24, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=53090
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=25, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=200038
;
-- Jul 17, 2013 6:34:45 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_TreeNodeMM SET Parent_ID=153, SeqNo=26, Updated=statement_timestamp() WHERE AD_Tree_ID=10 AND Node_ID=50001
;
-- Jul 17, 2013 7:12:19 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=19,Updated=TO_TIMESTAMP('2013-07-17 19:12:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200067
;
-- Jul 17, 2013 7:12:39 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=19,Updated=TO_TIMESTAMP('2013-07-17 19:12:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200069
;
-- Jul 17, 2013 7:12:49 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET AD_Reference_ID=19,Updated=TO_TIMESTAMP('2013-07-17 19:12:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200070
;
-- Jul 17, 2013 7:14:14 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Processed table: {0}, Processed foreign key: {1}, Error: {2}',200205,'D','2ea056aa-31ad-479b-8649-a9c7c202cbcb','CreateForeignKeyProcessResult','Y',TO_TIMESTAMP('2013-07-17 19:14:13','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-17 19:14:13','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 17, 2013 7:14:14 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200205 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 17, 2013 7:14:51 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Process table: ',200206,'D','e2a802b1-2a0d-4f80-859a-1c2ef7fd92c2','CreateForeignKeyProcessTable','Y',TO_TIMESTAMP('2013-07-17 19:14:47','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-17 19:14:47','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 17, 2013 7:14:51 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200206 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 18, 2013 6:00:55 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_TIMESTAMP('2013-07-18 18:00:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200069
;
-- Jul 19, 2013 6:02:32 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Process column: ',200209,'D','28924812-7226-4107-8c36-8447763bc7cd','CreateForeignKeyProcessColumn','Y',TO_TIMESTAMP('2013-07-19 18:02:30','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-19 18:02:30','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 19, 2013 6:02:32 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200209 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 19, 2013 6:05:21 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Foreign key already exists: ',200210,'D','fc625fe7-0dcb-455c-b4ba-7b5cc7dd2939','CreateForeignKeyProcessExists','Y',TO_TIMESTAMP('2013-07-19 18:05:20','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-07-19 18:05:20','YYYY-MM-DD HH24:MI:SS'),0)
;
-- Jul 19, 2013 6:05:21 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200210 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Jul 19, 2013 6:05:31 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Message SET MsgText='Foreign key already exists: ',Updated=TO_TIMESTAMP('2013-07-19 18:05:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200210
;
-- Jul 19, 2013 6:05:38 PM SGT
-- IDEMPIERE-1132 Improve AD_Index; AD_View; foreign keys management
UPDATE AD_Message_Trl SET MsgText='Foreign key already exists: ',Updated=TO_TIMESTAMP('2013-07-19 18:05:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200210 AND AD_Language='es_CO'
;
SELECT register_migration_script('201307191811_IDEMPIERE-1132.sql') FROM dual
;

View File

@ -20,13 +20,18 @@ import java.math.BigDecimal;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.DatabaseKey;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.util.AdempiereUserError; import org.compiere.util.AdempiereUserError;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
/** /**
@ -122,6 +127,106 @@ public class ColumnSync extends SvrProcess
else if (sql == null) else if (sql == null)
sql = column.getSQLAdd(table); sql = column.getSQLAdd(table);
// foreign key
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())))
{
int refid = column.getAD_Reference_ID();
if (refid != DisplayType.List && refid != DisplayType.Payment)
{
String referenceTableName = column.getReferenceTableName();
if (referenceTableName != null)
{
Hashtable<String, DatabaseKey> htForeignKeys = new Hashtable<String, DatabaseKey>();
if (md.storesUpperCaseIdentifiers())
referenceTableName = referenceTableName.toUpperCase();
else if (md.storesLowerCaseIdentifiers())
referenceTableName = referenceTableName.toLowerCase();
rs = md.getCrossReference(catalog, schema, referenceTableName, catalog, schema, tableName);
while (rs.next())
{
String dbFKName = rs.getString("FK_NAME");
if (dbFKName == null)
continue;
String dbFKTable = rs.getString("FKTABLE_NAME");
String key = dbFKName.toLowerCase();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey == null)
dbForeignKey = new DatabaseKey(dbFKName, dbFKTable, new String[30]);
String columnName = rs.getString("FKCOLUMN_NAME");
int pos = (rs.getShort("KEY_SEQ"));
if (pos > 0)
dbForeignKey.getKeyColumns()[pos-1] = columnName;
htForeignKeys.put(key, dbForeignKey);
}
rs.close();
Enumeration<String> en = htForeignKeys.keys();
while (en.hasMoreElements())
{
String key = en.nextElement();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey.getKeyColumns()[1] != null)
htForeignKeys.remove(key);
}
StringBuilder fkConstraintSql = new StringBuilder();
boolean modified = false;
en = htForeignKeys.keys();
while (en.hasMoreElements())
{
String key = en.nextElement();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey.getKeyColumns()[0].equalsIgnoreCase(column.getColumnName()))
{
DatabaseKey primaryKey = CreateForeignKey.getPrimaryKey(md, dbForeignKey.getKeyTable());
if (primaryKey != null)
{
StringBuilder fkConstraint = new StringBuilder();
fkConstraint.append("CONSTRAINT ").append(dbForeignKey.getKeyName());
fkConstraint.append(" FOREIGN KEY (").append(column.getColumnName()).append(") REFERENCES ");
fkConstraint.append(primaryKey.getKeyTable()).append("(").append(primaryKey.getKeyColumns()[0]);
for (int i = 1; i < primaryKey.getKeyColumns().length; i++)
{
if (primaryKey.getKeyColumns()[i] == null)
break;
fkConstraint.append(", ").append(primaryKey.getKeyColumns()[i]);
}
fkConstraint.append(")");
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
fkConstraintSql.append(" MODIFY ");
fkConstraintSql.append(fkConstraint);
}
modified = true;
break;
}
}
if (!modified)
{
String fkConstraint = CreateForeignKey.getForeignKeyConstraint(md, table, column);
if (fkConstraint != null && fkConstraint.length() > 0)
{
fkConstraintSql.append(DB.SQLSTATEMENT_SEPARATOR);
fkConstraintSql.append("ALTER TABLE ").append(table.getTableName());
fkConstraintSql.append(" ADD ");
fkConstraintSql.append(fkConstraint);
}
}
if (fkConstraintSql != null && fkConstraintSql.length() > 0)
sql += fkConstraintSql.toString();
}
}
}
int no = 0; int no = 0;
if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1) if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1)
{ {

View File

@ -0,0 +1,39 @@
package org.compiere.model;
public class DatabaseKey
{
private String keyName;
private String keyTable;
private String[] keyColumns;
public DatabaseKey(String keyName, String keyTable, String[] keyColumns)
{
this.keyName = keyName;
this.keyTable = keyTable;
this.keyColumns = keyColumns;
}
public String getKeyName() {
return keyName;
}
public void setKeyName(String keyName) {
this.keyName = keyName;
}
public String getKeyTable() {
return keyTable;
}
public void setKeyTable(String keyTable) {
this.keyTable = keyTable;
}
public String[] getKeyColumns() {
return keyColumns;
}
public void setKeyColumns(String[] keyColumns) {
this.keyColumns = keyColumns;
}
}

View File

@ -0,0 +1,400 @@
package org.compiere.process;
import java.math.BigDecimal;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.logging.Level;
import org.compiere.model.DatabaseKey;
import org.compiere.model.MColumn;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Msg;
import org.compiere.util.Trx;
public class CreateForeignKey extends SvrProcess {
/** Table */
private int p_AD_Table_ID = 0;
/** Column */
private int p_AD_Column_ID = 0;
private int countTable = 0;
private int countForeignKey = 0;
private int countError = 0;
@Override
protected void prepare()
{
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else if (name.equals("AD_Table_ID"))
p_AD_Table_ID = para[i].getParameterAsInt();
else if (name.equals("AD_Column_ID"))
p_AD_Column_ID = para[i].getParameterAsInt();
else
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
}
}
@Override
protected String doIt() throws Exception
{
if (log.isLoggable(Level.INFO)) log.info("AD_Table_ID=" + p_AD_Table_ID + ", AD_Column_ID=" + p_AD_Column_ID);
Trx trx = Trx.get(get_TrxName(), true);
DatabaseMetaData md = trx.getConnection().getMetaData();
if (p_AD_Column_ID > 0)
{
MColumn column = new MColumn(getCtx(), p_AD_Column_ID, get_TrxName());
if (column != null)
{
MTable table = new MTable(getCtx(), column.getAD_Table_ID(), get_TrxName());
if (table != null)
{
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())))
processDatabaseTableColumn(md, table, column);
}
}
}
else if (p_AD_Table_ID > 0)
{
MTable table = new MTable(getCtx(), p_AD_Table_ID, get_TrxName());
if (table != null)
processDatabaseTableColumn(md, table, null);
}
else
processDatabase(md);
trx.close();
return Msg.getMsg(getCtx(), "CreateForeignKeyProcessResult", new Object[] {countTable, countForeignKey, countError});
}
private void processDatabase(DatabaseMetaData md) throws Exception
{
String tableName = null;
String catalog = DB.getDatabase().getCatalog();
String schema = DB.getDatabase().getSchema();
String[] types = {"TABLE"};
ResultSet rs = md.getTables(catalog, schema, tableName, types);
while (rs.next())
{
String dbTableName = rs.getString("TABLE_NAME");
if (dbTableName == null)
continue;
MTable table = MTable.get(getCtx(), dbTableName);
if (table != null) // exists in AD_Table
processDatabaseTableColumn(md, table, null);
}
rs.close();
}
private void processDatabaseTableColumn(DatabaseMetaData md, MTable table, MColumn column) throws Exception
{
Hashtable<String, DatabaseKey> htForeignKeys = new Hashtable<String, DatabaseKey>();
String catalog = DB.getDatabase().getCatalog();
String schema = DB.getDatabase().getSchema();
String tableName = table.getTableName();
if (md.storesUpperCaseIdentifiers())
tableName = tableName.toUpperCase();
else if (md.storesLowerCaseIdentifiers())
tableName = tableName.toLowerCase();
addLog(Msg.getMsg(getCtx(), "CreateForeignKeyProcessTable") + tableName);
addLog(table.getAD_Table_ID(), null, null, table.toString(), table.get_Table_ID(), table.getAD_Table_ID());
++countTable;
if (column == null)
{
ResultSet rs = md.getImportedKeys(catalog, schema, tableName);
while (rs.next())
{
String dbFKName = rs.getString("FK_NAME");
if (dbFKName == null)
continue;
String dbFKTable = rs.getString("FKTABLE_NAME");
String key = dbFKName.toLowerCase();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey == null)
dbForeignKey = new DatabaseKey(dbFKName, dbFKTable, new String[30]);
String columnName = rs.getString("FKCOLUMN_NAME");
int pos = (rs.getShort("KEY_SEQ"));
if (pos > 0)
dbForeignKey.getKeyColumns()[pos-1] = columnName;
htForeignKeys.put(key, dbForeignKey);
}
rs.close();
Enumeration<String> en = htForeignKeys.keys();
while (en.hasMoreElements())
{
String key = en.nextElement();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey.getKeyColumns()[1] != null)
htForeignKeys.remove(key);
}
String getColumnIDSql = "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID = ? AND LOWER(ColumnName) = ?";
rs = md.getColumns(catalog, schema, tableName, null);
while (rs.next())
{
String columnName = rs.getString("COLUMN_NAME");
if (columnName == null)
continue;
int AD_Column_ID = DB.getSQLValue(null, getColumnIDSql, table.getAD_Table_ID(), columnName.toLowerCase());
if (AD_Column_ID > 0)
{
column = MColumn.get(getCtx(), AD_Column_ID);
if (column == null)
continue;
boolean modified = false;
en = htForeignKeys.keys();
while (en.hasMoreElements())
{
String key = en.nextElement();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey.getKeyColumns()[0].equalsIgnoreCase(column.getColumnName()))
{
addLog(Msg.getMsg(getCtx(), "CreateForeignKeyProcessColumn") + column.getColumnName());
addLog(column.getAD_Column_ID(), null, null, column.toString(), column.get_Table_ID(), column.getAD_Column_ID());
addLog(0, null, null, Msg.getMsg(getCtx(), "CreateForeignKeyProcessExists") + dbForeignKey.getKeyName());
modified = true;
break;
}
}
if (modified)
continue;
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())))
{
String fkConstraint = getForeignKeyConstraint(md, table, column);
if (fkConstraint != null && fkConstraint.length() > 0)
{
addLog(Msg.getMsg(getCtx(), "CreateForeignKeyProcessColumn") + column.getColumnName());
addLog(column.getAD_Column_ID(), null, null, column.toString(), column.get_Table_ID(), column.getAD_Column_ID());
StringBuilder sql = new StringBuilder();
sql.append("ALTER TABLE ").append(table.getTableName());
sql.append(" ADD ");
sql.append(fkConstraint);
Trx trx = Trx.get(Trx.createTrxName("CreateForeignKey"), true);
try {
int rvalue = DB.executeUpdate(sql.toString(), (Object[]) null, true, trx.getTrxName());
addLog(0, null, new BigDecimal(rvalue), sql.toString());
if (rvalue == -1)
++countError;
else
++countForeignKey;
} catch (Exception e) {
addLog(Msg.getMsg(getCtx(), "Error") + e.getLocalizedMessage());
if (trx != null)
trx.rollback();
++countError;
} finally {
if (trx != null)
trx.close();
}
}
}
}
}
rs.close();
}
else
{
int refid = column.getAD_Reference_ID();
if (refid != DisplayType.List && refid != DisplayType.Payment)
{
String referenceTableName = column.getReferenceTableName();
if (referenceTableName != null)
{
if (md.storesUpperCaseIdentifiers())
referenceTableName = referenceTableName.toUpperCase();
else if (md.storesLowerCaseIdentifiers())
referenceTableName = referenceTableName.toLowerCase();
ResultSet rs = md.getCrossReference(catalog, schema, referenceTableName, catalog, schema, tableName);
while (rs.next())
{
String dbFKName = rs.getString("FK_NAME");
if (dbFKName == null)
continue;
String dbFKTable = rs.getString("FKTABLE_NAME");
String key = dbFKName.toLowerCase();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey == null)
dbForeignKey = new DatabaseKey(dbFKName, dbFKTable, new String[30]);
String columnName = rs.getString("FKCOLUMN_NAME");
int pos = (rs.getShort("KEY_SEQ"));
if (pos > 0)
dbForeignKey.getKeyColumns()[pos-1] = columnName;
htForeignKeys.put(key, dbForeignKey);
}
rs.close();
Enumeration<String> en = htForeignKeys.keys();
while (en.hasMoreElements())
{
String key = en.nextElement();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey.getKeyColumns()[1] != null)
htForeignKeys.remove(key);
}
en = htForeignKeys.keys();
while (en.hasMoreElements())
{
String key = en.nextElement();
DatabaseKey dbForeignKey = htForeignKeys.get(key);
if (dbForeignKey.getKeyColumns()[0].equalsIgnoreCase(column.getColumnName()))
{
addLog(Msg.getMsg(getCtx(), "CreateForeignKeyProcessColumn") + column.getColumnName());
addLog(column.getAD_Column_ID(), null, null, column.toString(), column.get_Table_ID(), column.getAD_Column_ID());
addLog(0, null, null, Msg.getMsg(getCtx(), "CreateForeignKeyProcessExists") + dbForeignKey.getKeyName());
return;
}
}
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())))
{
String fkConstraint = getForeignKeyConstraint(md, table, column);
if (fkConstraint != null && fkConstraint.length() > 0)
{
addLog(Msg.getMsg(getCtx(), "CreateForeignKeyProcessColumn") + column.getColumnName());
addLog(column.getAD_Column_ID(), null, null, column.toString(), column.get_Table_ID(), column.getAD_Column_ID());
StringBuilder sql = new StringBuilder();
sql.append("ALTER TABLE ").append(table.getTableName());
sql.append(" ADD ");
sql.append(fkConstraint);
Trx trx = Trx.get(Trx.createTrxName("CreateForeignKey"), true);
try {
int rvalue = DB.executeUpdate(sql.toString(), (Object[]) null, true, trx.getTrxName());
addLog(0, null, new BigDecimal(rvalue), sql.toString());
if (rvalue == -1)
++countError;
else
++countForeignKey;
} catch (Exception e) {
addLog(Msg.getMsg(getCtx(), "Error") + e.getLocalizedMessage());
if (trx != null)
trx.rollback();
++countError;
} finally {
if (trx != null)
trx.close();
}
}
}
}
}
}
}
public static String getForeignKeyConstraint(DatabaseMetaData md, MTable table, MColumn column) throws Exception
{
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())))
{
int refid = column.getAD_Reference_ID();
if (refid != DisplayType.List && refid != DisplayType.Payment)
{
String referenceTableName = column.getReferenceTableName();
if (referenceTableName != null)
{
DatabaseKey primaryKey = getPrimaryKey(md, referenceTableName);
if (primaryKey != null)
{
String columnName = column.getColumnName();
if (columnName.toUpperCase().endsWith("_ID"))
columnName = columnName.substring(0, columnName.length() - 3);
StringBuilder constraintName = new StringBuilder();
constraintName.append(columnName.replace("_", ""));
constraintName.append("_");
constraintName.append(table.getTableName().replace("_", ""));
if (constraintName.length() > 30)
constraintName = new StringBuilder(constraintName.substring(0, 30));
StringBuilder fkConstraint = new StringBuilder();
fkConstraint.append("CONSTRAINT ").append(constraintName);
fkConstraint.append(" FOREIGN KEY (").append(column.getColumnName()).append(") REFERENCES ");
fkConstraint.append(primaryKey.getKeyTable()).append("(").append(primaryKey.getKeyColumns()[0]);
for (int i = 1; i < primaryKey.getKeyColumns().length; i++)
{
if (primaryKey.getKeyColumns()[i] == null)
break;
fkConstraint.append(", ").append(primaryKey.getKeyColumns()[i]);
}
fkConstraint.append(")");
return fkConstraint.toString();
}
}
}
}
return "";
}
public static DatabaseKey getPrimaryKey(DatabaseMetaData md, String primaryTableName) throws Exception
{
DatabaseKey primaryKey = null;
String catalog = DB.getDatabase().getCatalog();
String schema = DB.getDatabase().getSchema();
String tableName = primaryTableName;
if (md.storesUpperCaseIdentifiers())
tableName = tableName.toUpperCase();
else if (md.storesLowerCaseIdentifiers())
tableName = tableName.toLowerCase();
ResultSet rs = md.getPrimaryKeys(catalog, schema, tableName);
while (rs.next())
{
String primaryKeyName = rs.getString("PK_NAME");
if (primaryKeyName == null)
continue;
String primaryKeyTableName = rs.getString("TABLE_NAME");
if (primaryKey == null)
primaryKey = new DatabaseKey(primaryKeyName, primaryKeyTableName, new String[30]);
String primaryKeyColumn = rs.getString("COLUMN_NAME");
int pos = (rs.getShort("KEY_SEQ"));
if (pos > 0)
primaryKey.getKeyColumns()[pos-1] = primaryKeyColumn;
}
rs.close();
return primaryKey;
}
}

View File

@ -65,8 +65,8 @@ public class CreateTableIndex extends SvrProcess {
private void processDatabase(DatabaseMetaData md) throws Exception private void processDatabase(DatabaseMetaData md) throws Exception
{ {
String tableName = null; String tableName = null;
String catalog = null; String catalog = DB.getDatabase().getCatalog();
String schema = null; String schema = DB.getDatabase().getSchema();
String[] types = {"TABLE"}; String[] types = {"TABLE"};
ResultSet rs = md.getTables(catalog, schema, tableName, types); ResultSet rs = md.getTables(catalog, schema, tableName, types);
@ -86,8 +86,8 @@ public class CreateTableIndex extends SvrProcess {
private void processDatabaseTable(DatabaseMetaData md, MTable table) throws Exception private void processDatabaseTable(DatabaseMetaData md, MTable table) throws Exception
{ {
Hashtable<String, DatabaseTableIndex> htIndexes = new Hashtable<String, DatabaseTableIndex>(); Hashtable<String, DatabaseTableIndex> htIndexes = new Hashtable<String, DatabaseTableIndex>();
String catalog = "REFERENCE"; String catalog = DB.getDatabase().getCatalog();
String schema = null; String schema = DB.getDatabase().getSchema();
String tableName = table.getTableName(); String tableName = table.getTableName();
if (md.storesUpperCaseIdentifiers()) if (md.storesUpperCaseIdentifiers())
@ -130,8 +130,8 @@ public class CreateTableIndex extends SvrProcess {
private void processTableIndex(DatabaseMetaData md, MTable table, Hashtable<String, DatabaseTableIndex> htIndexes) throws Exception private void processTableIndex(DatabaseMetaData md, MTable table, Hashtable<String, DatabaseTableIndex> htIndexes) throws Exception
{ {
String catalog = null; String catalog = DB.getDatabase().getCatalog();
String schema = null; String schema = DB.getDatabase().getSchema();
String tableName = table.getTableName(); String tableName = table.getTableName();
if (md.storesUpperCaseIdentifiers()) if (md.storesUpperCaseIdentifiers())
@ -186,7 +186,7 @@ public class CreateTableIndex extends SvrProcess {
String dbIndexColumn = dbTableIndex.columns[i]; String dbIndexColumn = dbTableIndex.columns[i];
if (dbIndexColumn == null) if (dbIndexColumn == null)
break; break;
int AD_Column_ID = DB.getSQLValue(get_TrxName(), getColumnIDSql, table.getAD_Table_ID(), dbIndexColumn.toLowerCase()); int AD_Column_ID = DB.getSQLValue(null, getColumnIDSql, table.getAD_Table_ID(), dbIndexColumn.toLowerCase());
String columnName = dbIndexColumn; String columnName = dbIndexColumn;
if (AD_Column_ID > 0) if (AD_Column_ID > 0)