database/model/functions/AD_SYNCHRONIZE.xml
author Gorka Ion Damián <gorkaion.damian@openbravo.com>
Fri, 14 Dec 2007 16:21:33 +0000
changeset 239 a30acae847e1
parent 170 4b5493776a7f
child 735 daced7e311c9
permissions -rw-r--r--
Added CDATA to views, functions and triggers.
carlos@0
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="FUNCTION AD_SYNCHRONIZE">
adrian@94
     3
    <function name="AD_SYNCHRONIZE" type="NULL">
adrian@94
     4
      <parameter name="p_PInstance_ID" type="NUMERIC" mode="in"/>
gorkaion@239
     5
      <body><![CDATA[/*************************************************************************
carlos@0
     6
  * The contents of this file are subject to the Compiere License
carlos@0
     7
  * Version 2.5.0 ("License"); You may not use this file except in
carlos@0
     8
  * compliance with the License. You may obtain a copy of the License at
carlos@0
     9
  * http://www.compiere.org/license.html
carlos@0
    10
  * Software distributed under the License is distributed on an
carlos@0
    11
  * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
carlos@0
    12
  * implied. See the License for the specific language governing rights
carlos@0
    13
  * and limitations under the License.
gorkaion@239
    14
  * The Original Code is  Compiere  ERP &  Business Solution
carlos@0
    15
  * The Initial Developer of the Original Code is Jorg Janke  and ComPiere,
carlos@0
    16
  Inc.
carlos@0
    17
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
carlos@0
    18
  * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
carlos@0
    19
  * All Rights Reserved.
carlos@0
    20
  * Contributor(s): Openbravo SL
asier@130
    21
  * Contributions are Copyright (C) 1999-2007 Openbravo, S.L
carlos@0
    22
  *************************************************************************
carlos@0
    23
  * $Id: AD_Syncronize.sql,v 1.12 2003/07/26 04:29:44 jjanke Exp $
carlos@0
    24
  ***
carlos@0
    25
  * Title: Syncronize Application Dictionary
carlos@0
    26
  * Description:
carlos@0
    27
  *  Synchronize Elements
carlos@0
    28
  *  Update Column and Field with Names from Element and Process
carlos@0
    29
  *  Update Process Parameters from Elements
carlos@0
    30
  *  Update Workflow Notes from Windows
carlos@0
    31
  *  Update Menu from Window/Form/Process/Task
carlos@0
    32
  ************************************************************************/
carlos@0
    33
  -- Logistice
carlos@0
    34
  v_ResultStr VARCHAR2(2000):='';
carlos@0
    35
  v_Message VARCHAR2(2000):='';
carlos@0
    36
  v_Result NUMBER:=1; -- 0=failure
carlos@0
    37
  v_Record_ID NUMBER;
carlos@0
    38
  v_AD_User_ID NUMBER;
carlos@0
    39
  -- Parameter
carlos@0
    40
  TYPE RECORD IS REF CURSOR;
carlos@0
    41
    Cur_Parameter RECORD;
carlos@0
    42
    -- Parameter Variables
carlos@0
    43
    v_rowcount NUMBER;
carlos@0
    44
  BEGIN
carlos@0
    45
    IF(p_PInstance_ID IS NOT NULL) THEN
carlos@0
    46
      --  Update AD_PInstance
carlos@0
    47
      DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
carlos@0
    48
      v_ResultStr:='PInstanceNotFound';
carlos@0
    49
      Ad_Update_Pinstance(p_PInstance_ID, NULL, 'Y', NULL, NULL) ;
carlos@0
    50
      -- Get Parameters
carlos@0
    51
      v_ResultStr:='ReadingParameters';
carlos@0
    52
      FOR Cur_Parameter IN
carlos@0
    53
        (SELECT i.Record_ID, i.AD_User_ID, p.ParameterName, p.P_String, p.P_Number, p.P_Date
carlos@0
    54
        FROM AD_PINSTANCE i
carlos@0
    55
        LEFT JOIN AD_PINSTANCE_PARA p
carlos@0
    56
          ON i.AD_PInstance_ID=p.AD_PInstance_ID
carlos@0
    57
        WHERE i.AD_PInstance_ID=p_PInstance_ID
carlos@0
    58
        ORDER BY p.SeqNo
carlos@0
    59
        )
carlos@0
    60
      LOOP
carlos@0
    61
        v_Record_ID:=Cur_Parameter.Record_ID;
carlos@0
    62
        v_AD_User_ID:=Cur_Parameter.AD_User_ID;
carlos@0
    63
      END LOOP; -- Get Parameter
carlos@0
    64
      DBMS_OUTPUT.PUT_LINE('  Record_ID=' || v_Record_ID) ;
carlos@0
    65
    END IF;
carlos@0
    66
  BEGIN --BODY
carlos@0
    67
    ---------------------------------------------------------------------------
carlos@0
    68
    DBMS_OUTPUT.PUT_LINE('Adding missing Elements') ;
carlos@0
    69
    DECLARE
carlos@0
    70
      NextNo NUMBER;
carlos@0
    71
      Cur_Column RECORD;
carlos@0
    72
      Cur_Process RECORD;
carlos@0
    73
    BEGIN
carlos@0
    74
      DBMS_OUTPUT.PUT_LINE('Column:') ;
carlos@0
    75
      FOR Cur_Column IN
carlos@0
    76
        (SELECT DISTINCT ColumnName, NAME, Description, Help
carlos@0
    77
        FROM AD_COLUMN c
carlos@0
    78
        WHERE AD_Element_ID IS NULL  AND NOT EXISTS
carlos@0
    79
          (SELECT * FROM AD_ELEMENT e  WHERE UPPER(c.ColumnName)=UPPER(e.ColumnName))
carlos@0
    80
        )
carlos@0
    81
      LOOP
carlos@0
    82
        Ad_Sequence_Next('AD_Element', 0, NextNo) ; -- get ID
carlos@0
    83
        INSERT
carlos@0
    84
        INTO AD_ELEMENT
carlos@0
    85
          (
carlos@0
    86
            AD_ELEMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE,
carlos@0
    87
            CREATED, CREATEDBY, UPDATED, UPDATEDBY,
carlos@0
    88
            ColumnName, NAME, PrintName, Description,
carlos@0
    89
            Help
carlos@0
    90
          )
carlos@0
    91
          VALUES
carlos@0
    92
          (NextNo, 0, 0, 'Y',
carlos@0
    93
          Now(), 0, Now(), 0,
carlos@0
    94
          Cur_Column.ColumnName, Cur_Column.NAME, Cur_Column.NAME, Cur_Column.Description,
carlos@0
    95
          Cur_Column.Help) ;
carlos@0
    96
        DBMS_OUTPUT.PUT_LINE('  added ' || Cur_Column.ColumnName) ;
carlos@0
    97
        COMMIT;
carlos@0
    98
      END LOOP;
carlos@0
    99
      DBMS_OUTPUT.PUT_LINE('Parameter:') ;
carlos@0
   100
      FOR Cur_Process IN
carlos@0
   101
        (SELECT DISTINCT ColumnName, NAME, Description, Help
carlos@0
   102
      FROM AD_PROCESS_PARA p
carlos@0
   103
      WHERE AD_Element_ID IS NULL  AND NOT EXISTS
carlos@0
   104
        (SELECT * FROM AD_ELEMENT e  WHERE UPPER(p.ColumnName)=UPPER(e.ColumnName))
carlos@0
   105
        )
carlos@0
   106
      LOOP
carlos@0
   107
        Ad_Sequence_Next('AD_Element', 0, NextNo) ; -- get ID
carlos@0
   108
        INSERT
carlos@0
   109
        INTO AD_ELEMENT
carlos@0
   110
          (
carlos@0
   111
            AD_ELEMENT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE,
carlos@0
   112
            CREATED, CREATEDBY, UPDATED, UPDATEDBY,
carlos@0
   113
            ColumnName, NAME, PrintName, Description,
carlos@0
   114
            Help
carlos@0
   115
          )
carlos@0
   116
          VALUES
carlos@0
   117
          (NextNo, 0, 0, 'Y',
carlos@0
   118
          Now(), 0, Now(), 0,
carlos@0
   119
          Cur_Process.ColumnName, Cur_Process.NAME, Cur_Process.NAME, Cur_Process.Description,
carlos@0
   120
          Cur_Process.Help) ;
carlos@0
   121
        DBMS_OUTPUT.PUT_LINE('  added ' || Cur_Process.ColumnName) ;
carlos@0
   122
        COMMIT;
carlos@0
   123
      END LOOP;
carlos@0
   124
    END;
carlos@0
   125
    DBMS_OUTPUT.PUT_LINE('Adding missing Element Translations') ;
carlos@0
   126
    INSERT
carlos@0
   127
    INTO AD_ELEMENT_TRL
carlos@0
   128
      (
carlos@0
   129
        AD_Element_ID, AD_LANGUAGE, AD_Client_ID, AD_Org_ID,
carlos@0
   130
        IsActive, Created, CreatedBy, Updated,
carlos@0
   131
        UpdatedBy, NAME, PrintName, Description,
carlos@0
   132
        Help, IsTranslated
carlos@0
   133
      )
carlos@0
   134
    SELECT m.AD_Element_ID, l.AD_LANGUAGE, m.AD_Client_ID, m.AD_Org_ID, m.IsActive, m.Created, m.CreatedBy, m.Updated, m.UpdatedBy, m.NAME, m.PrintName, m.Description, m.Help, 'N'
carlos@0
   135
    FROM AD_ELEMENT m, AD_LANGUAGE l
carlos@0
   136
    WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y'  AND AD_Element_ID || AD_LANGUAGE NOT IN
carlos@0
   137
      (SELECT AD_Element_ID || AD_LANGUAGE FROM AD_ELEMENT_TRL)
carlos@0
   138
      ;
carlos@0
   139
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   140
    DBMS_OUTPUT.PUT_LINE('  rows added: ' || v_rowcount) ;
carlos@0
   141
    DBMS_OUTPUT.PUT_LINE('Deleting unused Elements') ;
carlos@0
   142
    DELETE
carlos@0
   143
    FROM AD_ELEMENT_TRL
carlos@0
   144
    WHERE AD_Element_ID IN
carlos@0
   145
      (SELECT AD_Element_ID
carlos@0
   146
      FROM AD_ELEMENT e
carlos@0
   147
      WHERE NOT EXISTS
carlos@0
   148
        (SELECT *
carlos@0
   149
        FROM AD_COLUMN c
carlos@0
   150
        WHERE UPPER(e.ColumnName)=UPPER(c.ColumnName) OR e.AD_Element_ID=c.AD_Element_ID
carlos@0
   151
        )
carlos@0
   152
        AND NOT EXISTS
carlos@0
   153
        (SELECT *
carlos@0
   154
        FROM AD_PROCESS_PARA p
carlos@0
   155
        WHERE UPPER(e.ColumnName)=UPPER(p.ColumnName) OR e.AD_Element_ID=p.AD_Element_ID
carlos@0
   156
        )
carlos@0
   157
      )
carlos@0
   158
      ;
carlos@0
   159
    DELETE
carlos@0
   160
    FROM AD_ELEMENT
carlos@0
   161
    WHERE NOT EXISTS
carlos@0
   162
      (SELECT *
carlos@0
   163
      FROM AD_COLUMN c
carlos@0
   164
      WHERE UPPER(AD_ELEMENT.ColumnName)=UPPER(c.ColumnName) OR AD_ELEMENT.AD_Element_ID=c.AD_Element_ID
carlos@0
   165
      )
carlos@0
   166
      AND NOT EXISTS
carlos@0
   167
      (SELECT *
carlos@0
   168
      FROM AD_PROCESS_PARA p
carlos@0
   169
      WHERE UPPER(AD_ELEMENT.ColumnName)=UPPER(p.ColumnName) OR AD_ELEMENT.AD_Element_ID=p.AD_Element_ID
carlos@0
   170
      )
carlos@0
   171
      ;
carlos@0
   172
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   173
    DBMS_OUTPUT.PUT_LINE('  rows deleted: ' || v_rowcount) ;
carlos@0
   174
    DBMS_OUTPUT.PUT_LINE('Creating link from Element to Column') ;
carlos@0
   175
    UPDATE AD_COLUMN
carlos@0
   176
      SET AD_Element_id=
carlos@0
   177
      (SELECT MAX(AD_Element_ID)
carlos@0
   178
      FROM AD_ELEMENT e
carlos@0
   179
      WHERE UPPER(AD_COLUMN.ColumnName)=UPPER(e.ColumnName)
carlos@0
   180
      )
carlos@0
   181
    WHERE AD_Element_ID IS NULL;
carlos@0
   182
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   183
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   184
    DBMS_OUTPUT.PUT_LINE('Creating link from Element to Process Para') ;
carlos@0
   185
    UPDATE AD_PROCESS_PARA
carlos@0
   186
      SET AD_Element_id=
carlos@0
   187
      (SELECT MAX(AD_Element_ID)
carlos@0
   188
      FROM AD_ELEMENT e
carlos@0
   189
      WHERE UPPER(AD_PROCESS_PARA.ColumnName)=UPPER(e.ColumnName)
carlos@0
   190
      )
carlos@0
   191
    WHERE AD_Element_ID IS NULL;
carlos@0
   192
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   193
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   194
    COMMIT;
carlos@0
   195
    ---------------------------------------------------------------------------
carlos@0
   196
    -- Columns
carlos@0
   197
    DBMS_OUTPUT.PUT_LINE('Synchronize Column') ;
carlos@0
   198
    UPDATE AD_COLUMN
carlos@0
   199
      SET --ColumnName = (SELECT ColumnName FROM AD_Element e WHERE AD_Column.AD_Element_ID=e.AD_Element_ID),
carlos@0
   200
      NAME=
carlos@0
   201
      (SELECT NAME FROM AD_ELEMENT e WHERE AD_COLUMN.AD_Element_ID=e.AD_Element_ID)
carlos@0
   202
      , Description=
carlos@0
   203
      (SELECT Description
carlos@0
   204
      FROM AD_ELEMENT e
carlos@0
   205
      WHERE AD_COLUMN.AD_Element_ID=e.AD_Element_ID
carlos@0
   206
      )
carlos@0
   207
      , Help=
carlos@0
   208
      (SELECT Help FROM AD_ELEMENT e WHERE AD_COLUMN.AD_Element_ID=e.AD_Element_ID)
carlos@0
   209
      , Updated=Now()
carlos@0
   210
    WHERE EXISTS
carlos@0
   211
      (SELECT *
carlos@0
   212
      FROM AD_ELEMENT e
gorkaion@239
   213
      WHERE AD_COLUMN.AD_Element_ID=e.AD_Element_ID  AND(--AD_Column.ColumnName <> e.ColumnName OR
gorkaion@239
   214
        AD_COLUMN.NAME<>e.NAME  OR COALESCE(TO_CHAR(AD_COLUMN.Description), ' ')<>COALESCE(TO_CHAR(e.Description), ' ')
gorkaion@239
   215
        OR COALESCE(TO_CHAR(AD_COLUMN.Help), ' ')<>COALESCE(TO_CHAR(e.Help), ' '))
carlos@0
   216
      )
carlos@0
   217
      ;
carlos@0
   218
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   219
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   220
    -- Fields should now be syncronized
carlos@0
   221
    DBMS_OUTPUT.PUT_LINE('Synchronize Field') ;
carlos@0
   222
    UPDATE AD_FIELD
carlos@0
   223
      SET NAME=
carlos@0
   224
      (SELECT e.NAME
carlos@0
   225
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   226
      WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   227
      )
carlos@0
   228
      , Description=
carlos@0
   229
      (SELECT e.Description
carlos@0
   230
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   231
      WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   232
      )
carlos@0
   233
      , Help=
carlos@0
   234
      (SELECT e.Help
carlos@0
   235
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   236
      WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   237
      )
carlos@0
   238
      , Updated=Now()
carlos@0
   239
    WHERE AD_FIELD.IsCentrallyMaintained='Y' AND AD_FIELD.IsActive='Y'  AND EXISTS
carlos@0
   240
      (SELECT *
carlos@0
   241
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   242
      WHERE AD_FIELD.AD_Column_ID=c.AD_Column_ID  AND c.AD_Element_ID=e.AD_Element_ID
gorkaion@239
   243
      AND c.AD_Process_ID IS NULL  AND(AD_FIELD.NAME<>e.NAME OR COALESCE(TO_CHAR(AD_FIELD.Description), ' ')<>COALESCE(TO_CHAR(e.Description), ' ')
gorkaion@239
   244
      OR COALESCE(TO_CHAR(AD_FIELD.Help), ' ')<>COALESCE(TO_CHAR(e.Help), ' '))
asier@130
   245
      )AND NOT EXISTS
asier@130
   246
      (SELECT 1
asier@130
   247
      FROM AD_TAB t, AD_WINDOW w
asier@130
   248
      WHERE AD_FIELD.AD_Tab_ID=t.AD_Tab_ID  AND t.AD_Window_ID=w.AD_Window_ID  AND w.IsSOTrx='N'
asier@130
   249
      );
carlos@0
   250
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   251
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   252
    -- Field Translations
carlos@0
   253
    DBMS_OUTPUT.PUT_LINE('Synchronize Field Translations') ;
carlos@0
   254
    UPDATE AD_FIELD_TRL
carlos@0
   255
      SET NAME=
carlos@0
   256
      (SELECT e.NAME
carlos@0
   257
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   258
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   259
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   260
      )
carlos@0
   261
      , Description=
carlos@0
   262
      (SELECT e.Description
carlos@0
   263
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   264
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   265
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   266
      )
carlos@0
   267
      , Help=
carlos@0
   268
      (SELECT e.Help
carlos@0
   269
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   270
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   271
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   272
      )
carlos@0
   273
      , IsTranslated=
carlos@0
   274
      (SELECT e.IsTranslated
carlos@0
   275
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   276
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   277
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   278
      )
carlos@0
   279
      , Updated=Now()
carlos@0
   280
    WHERE EXISTS
carlos@0
   281
      (SELECT *
carlos@0
   282
      FROM AD_FIELD f, AD_ELEMENT_TRL e, AD_COLUMN c
carlos@0
   283
      WHERE AD_FIELD_TRL.AD_Field_ID=f.AD_Field_ID  AND f.AD_Column_ID=c.AD_Column_ID
carlos@0
   284
      AND c.AD_Element_ID=e.AD_Element_ID AND c.AD_Process_ID IS NULL
carlos@0
   285
      AND AD_FIELD_TRL.AD_LANGUAGE=e.AD_LANGUAGE  AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'
gorkaion@239
   286
      AND(AD_FIELD_TRL.NAME<>e.NAME OR COALESCE(TO_CHAR(AD_FIELD_TRL.Description), ' ')<>COALESCE(TO_CHAR(e.Description), ' ')
gorkaion@239
   287
      OR COALESCE(TO_CHAR(AD_FIELD_TRL.Help), ' ')<>COALESCE(TO_CHAR(e.Help), ' '))
asier@130
   288
      ) AND NOT EXISTS
asier@130
   289
      (SELECT 1
asier@130
   290
      FROM AD_FIELD f, AD_TAB t, AD_WINDOW w
asier@130
   291
      WHERE AD_FIELD_TRL.AD_Field_ID=f.AD_Field_ID  AND f.AD_Tab_ID=t.AD_Tab_ID
asier@130
   292
      AND t.AD_Window_ID=w.AD_Window_ID  AND w.IsSOTrx='N'
asier@130
   293
      )
asier@130
   294
      ;
carlos@0
   295
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   296
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   297
    -- Fields should now be syncronized
carlos@0
   298
    DBMS_OUTPUT.PUT_LINE('Synchronize PO Field') ;
carlos@0
   299
    UPDATE AD_FIELD
carlos@0
   300
      SET NAME=
carlos@0
   301
      (SELECT e.PO_Name
carlos@0
   302
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   303
      WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   304
      )
carlos@0
   305
      , Description=
carlos@0
   306
      (SELECT e.PO_Description
carlos@0
   307
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   308
      WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   309
      )
carlos@0
   310
      , Help=
carlos@0
   311
      (SELECT e.PO_Help
carlos@0
   312
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   313
      WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   314
      )
carlos@0
   315
      , Updated=Now()
carlos@0
   316
    WHERE AD_FIELD.IsCentrallyMaintained='Y' AND AD_FIELD.IsActive='Y'  AND EXISTS
carlos@0
   317
      (SELECT *
carlos@0
   318
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   319
      WHERE AD_FIELD.AD_Column_ID=c.AD_Column_ID  AND c.AD_Element_ID=e.AD_Element_ID
gorkaion@239
   320
      AND c.AD_Process_ID IS NULL  AND(AD_FIELD.NAME<>e.PO_Name OR COALESCE(TO_CHAR(AD_FIELD.Description), ' ')<>COALESCE(TO_CHAR(e.PO_Description), ' ')
gorkaion@239
   321
      OR COALESCE(TO_CHAR(AD_FIELD.Help), ' ')<>COALESCE(TO_CHAR(e.PO_Help), ' ')) AND e.PO_Name IS NOT NULL
carlos@0
   322
      )
carlos@0
   323
      AND EXISTS
carlos@0
   324
      (SELECT *
carlos@0
   325
      FROM AD_TAB t, AD_WINDOW w
carlos@0
   326
      WHERE AD_FIELD.AD_Tab_ID=t.AD_Tab_ID  AND t.AD_Window_ID=w.AD_Window_ID  AND w.IsSOTrx='N'
carlos@0
   327
      )
carlos@0
   328
      ;
carlos@0
   329
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   330
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   331
    -- Field Translations
carlos@0
   332
    DBMS_OUTPUT.PUT_LINE('Synchronize PO Field Translations') ;
carlos@0
   333
    UPDATE AD_FIELD_TRL
carlos@0
   334
      SET NAME=
carlos@0
   335
      (SELECT e.PO_Name
carlos@0
   336
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   337
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   338
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   339
      )
carlos@0
   340
      , Description=
carlos@0
   341
      (SELECT e.PO_Description
carlos@0
   342
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   343
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   344
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   345
      )
carlos@0
   346
      , Help=
carlos@0
   347
      (SELECT e.PO_Help
carlos@0
   348
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   349
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   350
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   351
      )
carlos@0
   352
      , IsTranslated=
carlos@0
   353
      (SELECT e.IsTranslated
carlos@0
   354
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_FIELD f
carlos@0
   355
      WHERE e.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   356
      AND c.AD_Column_ID=f.AD_Column_ID AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   357
      )
carlos@0
   358
      , Updated=Now()
carlos@0
   359
    WHERE EXISTS
carlos@0
   360
      (SELECT *
carlos@0
   361
      FROM AD_FIELD f, AD_ELEMENT_TRL e, AD_COLUMN c
carlos@0
   362
      WHERE AD_FIELD_TRL.AD_Field_ID=f.AD_Field_ID  AND f.AD_Column_ID=c.AD_Column_ID
carlos@0
   363
      AND c.AD_Element_ID=e.AD_Element_ID AND c.AD_Process_ID IS NULL
carlos@0
   364
      AND AD_FIELD_TRL.AD_LANGUAGE=e.AD_LANGUAGE  AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'
gorkaion@239
   365
      AND(AD_FIELD_TRL.NAME<>e.PO_Name OR COALESCE(TO_CHAR(AD_FIELD_TRL.Description), ' ')<>COALESCE(TO_CHAR(e.PO_Description), ' ')
gorkaion@239
   366
      OR COALESCE(TO_CHAR(AD_FIELD_TRL.Help), ' ')<>COALESCE(TO_CHAR(e.PO_Help), ' ')) AND e.PO_Name IS NOT NULL
carlos@0
   367
      )
carlos@0
   368
      AND EXISTS
carlos@0
   369
      (SELECT *
carlos@0
   370
      FROM AD_FIELD f, AD_TAB t, AD_WINDOW w
carlos@0
   371
      WHERE AD_FIELD_TRL.AD_Field_ID=f.AD_Field_ID  AND f.AD_Tab_ID=t.AD_Tab_ID
carlos@0
   372
      AND t.AD_Window_ID=w.AD_Window_ID  AND w.IsSOTrx='N'
carlos@0
   373
      )
carlos@0
   374
      ;
carlos@0
   375
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   376
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   377
    -- Fields from Process
carlos@0
   378
    DBMS_OUTPUT.PUT_LINE('Synchronize Field from Process') ;
carlos@0
   379
    UPDATE AD_FIELD
carlos@0
   380
      SET NAME=
carlos@0
   381
      (SELECT p.NAME
carlos@0
   382
      FROM AD_PROCESS p, AD_COLUMN c
carlos@0
   383
      WHERE p.AD_Process_ID=c.AD_Process_ID  AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   384
      )
carlos@0
   385
      , Description=
carlos@0
   386
      (SELECT p.Description
carlos@0
   387
      FROM AD_PROCESS p, AD_COLUMN c
carlos@0
   388
      WHERE p.AD_Process_ID=c.AD_Process_ID  AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   389
      )
carlos@0
   390
      , Help=
carlos@0
   391
      (SELECT p.Help
carlos@0
   392
      FROM AD_PROCESS p, AD_COLUMN c
carlos@0
   393
      WHERE p.AD_Process_ID=c.AD_Process_ID  AND c.AD_Column_ID=AD_FIELD.AD_Column_ID
carlos@0
   394
      )
carlos@0
   395
      , Updated=Now()
carlos@0
   396
    WHERE AD_FIELD.IsCentrallyMaintained='Y' AND AD_FIELD.IsActive='Y'  AND EXISTS
carlos@0
   397
      (SELECT *
carlos@0
   398
      FROM AD_PROCESS p, AD_COLUMN c
carlos@0
   399
      WHERE c.AD_Process_ID=p.AD_Process_ID AND AD_FIELD.AD_Column_ID=c.AD_Column_ID
gorkaion@239
   400
      AND(AD_FIELD.NAME<>p.NAME OR COALESCE(TO_CHAR(AD_FIELD.Description), ' ')<>COALESCE(TO_CHAR(p.Description), ' ')
gorkaion@239
   401
      OR COALESCE(TO_CHAR(AD_FIELD.Help), ' ')<>COALESCE(TO_CHAR(p.Help), ' '))
carlos@0
   402
      )
carlos@0
   403
      ;
carlos@0
   404
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   405
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   406
    -- Field Translations from Process
carlos@0
   407
    DBMS_OUTPUT.PUT_LINE('Synchronize Field Trl from Process Trl') ;
carlos@0
   408
    UPDATE AD_FIELD_TRL
carlos@0
   409
      SET NAME=
carlos@0
   410
      (SELECT p.NAME
carlos@0
   411
      FROM AD_PROCESS_TRL p, AD_COLUMN c, AD_FIELD f
carlos@0
   412
      WHERE p.AD_Process_ID=c.AD_Process_ID AND c.AD_Column_ID=f.AD_Column_ID  AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   413
      AND p.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE
carlos@0
   414
      )
carlos@0
   415
      , Description=
carlos@0
   416
      (SELECT p.Description
carlos@0
   417
      FROM AD_PROCESS_TRL p, AD_COLUMN c, AD_FIELD f
carlos@0
   418
      WHERE p.AD_Process_ID=c.AD_Process_ID AND c.AD_Column_ID=f.AD_Column_ID  AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   419
      AND p.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE
carlos@0
   420
      )
carlos@0
   421
      , Help=
carlos@0
   422
      (SELECT p.Help
carlos@0
   423
      FROM AD_PROCESS_TRL p, AD_COLUMN c, AD_FIELD f
carlos@0
   424
      WHERE p.AD_Process_ID=c.AD_Process_ID AND c.AD_Column_ID=f.AD_Column_ID  AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   425
      AND p.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE
carlos@0
   426
      )
carlos@0
   427
      , IsTranslated=
carlos@0
   428
      (SELECT p.IsTranslated
carlos@0
   429
      FROM AD_PROCESS_TRL p, AD_COLUMN c, AD_FIELD f
carlos@0
   430
      WHERE p.AD_Process_ID=c.AD_Process_ID AND c.AD_Column_ID=f.AD_Column_ID  AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
carlos@0
   431
      AND p.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE
carlos@0
   432
      )
carlos@0
   433
      , Updated=Now()
carlos@0
   434
    WHERE EXISTS
carlos@0
   435
      (SELECT *
carlos@0
   436
      FROM AD_PROCESS_TRL p, AD_COLUMN c, AD_FIELD f
carlos@0
   437
      WHERE c.AD_Process_ID=p.AD_Process_ID AND f.AD_Column_ID=c.AD_Column_ID  AND f.AD_Field_ID=AD_FIELD_TRL.AD_Field_ID
gorkaion@239
   438
      AND p.AD_LANGUAGE=AD_FIELD_TRL.AD_LANGUAGE  AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'  AND(AD_FIELD_TRL.NAME<>p.NAME
gorkaion@239
   439
      OR COALESCE(TO_CHAR(AD_FIELD_TRL.Description), ' ')<>COALESCE(TO_CHAR(p.Description), ' ') OR COALESCE(TO_CHAR(AD_FIELD_TRL.Help), ' ')<>COALESCE(TO_CHAR(p.Help), ' '))
carlos@0
   440
      );
carlos@0
   441
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   442
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   443
    -- Sync Parameter ColumnName
carlos@0
   444
    /*UPDATE AD_Process_Para
carlos@0
   445
    SET ColumnName = (SELECT e.ColumnName FROM AD_Element e
carlos@0
   446
    WHERE UPPER(e.ColumnName)=UPPER(AD_Process_Para.ColumnName))
carlos@0
   447
    WHERE AD_Process_Para.IsCentrallyMaintained='Y' AND AD_Process_Para.IsActive='Y'
carlos@0
   448
    AND EXISTS (SELECT * FROM AD_Element e
carlos@0
   449
    WHERE e.AD_Element_ID=AD_Process_Para.AD_Element_ID
gorkaion@239
   450
    AND e.ColumnName<>AD_Process_Para.ColumnName);*/
carlos@0
   451
    -- Paramenter Fields
carlos@0
   452
    UPDATE AD_PROCESS_PARA
carlos@0
   453
      SET IsCentrallyMaintained='N'
gorkaion@239
   454
    WHERE IsCentrallyMaintained<>'N'  AND NOT EXISTS
carlos@0
   455
      (SELECT *
carlos@0
   456
      FROM AD_ELEMENT e
carlos@0
   457
      WHERE AD_PROCESS_PARA.AD_Element_ID=e.AD_Element_ID
carlos@0
   458
      )
carlos@0
   459
      ;
carlos@0
   460
    -- Parameter Fields
carlos@0
   461
    DBMS_OUTPUT.PUT_LINE('Synchronize Process Parameter') ;
carlos@0
   462
    UPDATE AD_PROCESS_PARA
carlos@0
   463
      SET NAME=
carlos@0
   464
      (SELECT e.NAME
carlos@0
   465
      FROM AD_ELEMENT e
carlos@0
   466
      WHERE e.AD_Element_ID=AD_PROCESS_PARA.AD_Element_ID
carlos@0
   467
      )
carlos@0
   468
      , Description=
carlos@0
   469
      (SELECT e.Description
carlos@0
   470
      FROM AD_ELEMENT e
carlos@0
   471
      WHERE e.AD_Element_ID=AD_PROCESS_PARA.AD_Element_ID
carlos@0
   472
      )
carlos@0
   473
      , Help=
carlos@0
   474
      (SELECT e.Help
carlos@0
   475
      FROM AD_ELEMENT e
carlos@0
   476
      WHERE e.AD_Element_ID=AD_PROCESS_PARA.AD_Element_ID
carlos@0
   477
      )
carlos@0
   478
      , Updated=Now()
carlos@0
   479
    WHERE AD_PROCESS_PARA.IsCentrallyMaintained='Y' AND AD_PROCESS_PARA.IsActive='Y'  AND EXISTS
carlos@0
   480
      (SELECT *
carlos@0
   481
      FROM AD_ELEMENT e
gorkaion@239
   482
      WHERE e.AD_Element_ID=AD_PROCESS_PARA.AD_Element_ID  AND(AD_PROCESS_PARA.NAME<>e.NAME
gorkaion@239
   483
      OR COALESCE(TO_CHAR(AD_PROCESS_PARA.Description), ' ')<>COALESCE(TO_CHAR(e.Description), ' ')
gorkaion@239
   484
      OR COALESCE(TO_CHAR(AD_PROCESS_PARA.Help), ' ')<>COALESCE(TO_CHAR(e.Help), ' '))
carlos@0
   485
      )
carlos@0
   486
      ;
carlos@0
   487
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   488
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   489
    -- Parameter Translations
carlos@0
   490
    DBMS_OUTPUT.PUT_LINE('Synchronize Process Parameter Trl') ;
carlos@0
   491
    UPDATE AD_PROCESS_PARA_TRL
carlos@0
   492
      SET NAME=
carlos@0
   493
      (SELECT et.NAME
carlos@0
   494
      FROM AD_ELEMENT_TRL et, AD_PROCESS_PARA f
carlos@0
   495
      WHERE et.AD_LANGUAGE=AD_PROCESS_PARA_TRL.AD_LANGUAGE AND f.AD_Element_ID=et.AD_Element_ID
carlos@0
   496
      AND f.AD_Process_Para_ID=AD_PROCESS_PARA_TRL.AD_Process_Para_ID
carlos@0
   497
      )
carlos@0
   498
      , Description=
carlos@0
   499
      (SELECT et.Description
carlos@0
   500
      FROM AD_ELEMENT_TRL et, AD_PROCESS_PARA f
carlos@0
   501
      WHERE et.AD_LANGUAGE=AD_PROCESS_PARA_TRL.AD_LANGUAGE AND f.AD_Element_ID=et.AD_Element_ID
carlos@0
   502
      AND f.AD_Process_Para_ID=AD_PROCESS_PARA_TRL.AD_Process_Para_ID
carlos@0
   503
      )
carlos@0
   504
      , Help=
carlos@0
   505
      (SELECT et.Help
carlos@0
   506
      FROM AD_ELEMENT_TRL et, AD_PROCESS_PARA f
carlos@0
   507
      WHERE et.AD_LANGUAGE=AD_PROCESS_PARA_TRL.AD_LANGUAGE AND f.AD_Element_ID=et.AD_Element_ID
carlos@0
   508
      AND f.AD_Process_Para_ID=AD_PROCESS_PARA_TRL.AD_Process_Para_ID
carlos@0
   509
      )
carlos@0
   510
      , IsTranslated=
carlos@0
   511
      (SELECT et.IsTranslated
carlos@0
   512
      FROM AD_ELEMENT_TRL et, AD_PROCESS_PARA f
carlos@0
   513
      WHERE et.AD_LANGUAGE=AD_PROCESS_PARA_TRL.AD_LANGUAGE AND f.AD_Element_ID=et.AD_Element_ID
carlos@0
   514
      AND f.AD_Process_Para_ID=AD_PROCESS_PARA_TRL.AD_Process_Para_ID
carlos@0
   515
      )
carlos@0
   516
      , Updated=Now()
carlos@0
   517
    WHERE EXISTS
carlos@0
   518
      (SELECT *
carlos@0
   519
      FROM AD_ELEMENT_TRL et, AD_PROCESS_PARA f
carlos@0
   520
      WHERE et.AD_LANGUAGE=AD_PROCESS_PARA_TRL.AD_LANGUAGE AND f.AD_Element_ID=et.AD_Element_ID
carlos@0
   521
      AND f.AD_Process_Para_ID=AD_PROCESS_PARA_TRL.AD_Process_Para_ID  AND f.IsCentrallyMaintained='Y'
gorkaion@239
   522
      AND f.IsActive='Y'  AND(AD_PROCESS_PARA_TRL.NAME<>et.NAME OR COALESCE(TO_CHAR(AD_PROCESS_PARA_TRL.Description), ' ')<>COALESCE(TO_CHAR(et.Description), ' ')
gorkaion@239
   523
      OR COALESCE(TO_CHAR(AD_PROCESS_PARA_TRL.Help), ' ')<>COALESCE(TO_CHAR(et.Help), ' '))
carlos@0
   524
      );
carlos@0
   525
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   526
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   527
    -- Workflow Node - Window
carlos@0
   528
    DBMS_OUTPUT.PUT_LINE('Synchronize Workflow Node from Window') ;
carlos@0
   529
    UPDATE AD_WF_NODE
carlos@0
   530
      SET NAME=
carlos@0
   531
      (SELECT w.NAME FROM AD_WINDOW w  WHERE w.AD_Window_ID=AD_WF_NODE.AD_Window_ID)
carlos@0
   532
      , Description=
carlos@0
   533
      (SELECT w.Description
carlos@0
   534
      FROM AD_WINDOW w
carlos@0
   535
      WHERE w.AD_Window_ID=AD_WF_NODE.AD_Window_ID
carlos@0
   536
      )
carlos@0
   537
      , Help=
carlos@0
   538
      (SELECT w.Help FROM AD_WINDOW w  WHERE w.AD_Window_ID=AD_WF_NODE.AD_Window_ID)
carlos@0
   539
    WHERE AD_WF_NODE.IsCentrallyMaintained='Y'  AND EXISTS
carlos@0
   540
      (SELECT *
carlos@0
   541
      FROM AD_WINDOW w
gorkaion@239
   542
      WHERE w.AD_Window_ID=AD_WF_NODE.AD_Window_ID  AND(w.NAME<>AD_WF_NODE.NAME OR COALESCE(TO_CHAR(w.Description), ' ')<>COALESCE(TO_CHAR(AD_WF_NODE.Description), ' ')
gorkaion@239
   543
      OR COALESCE(TO_CHAR(w.Help), ' ')<>COALESCE(TO_CHAR(AD_WF_NODE.Help), ' '))
carlos@0
   544
      )
carlos@0
   545
      ;
carlos@0
   546
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   547
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   548
    -- Workflow Translations - Window
carlos@0
   549
    DBMS_OUTPUT.PUT_LINE('Synchronize Workflow Node Trl from Window Trl') ;
carlos@0
   550
    UPDATE AD_WF_NODE_TRL
carlos@0
   551
      SET NAME=
carlos@0
   552
      (SELECT t.NAME
carlos@0
   553
      FROM AD_WINDOW_TRL t, AD_WF_NODE n
carlos@0
   554
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Window_ID=t.AD_Window_ID
carlos@0
   555
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE
carlos@0
   556
      )
carlos@0
   557
      , Description=
carlos@0
   558
      (SELECT t.Description
carlos@0
   559
      FROM AD_WINDOW_TRL t, AD_WF_NODE n
carlos@0
   560
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Window_ID=t.AD_Window_ID
carlos@0
   561
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE
carlos@0
   562
      )
carlos@0
   563
      , Help=
carlos@0
   564
      (SELECT t.Help
carlos@0
   565
      FROM AD_WINDOW_TRL t, AD_WF_NODE n
carlos@0
   566
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Window_ID=t.AD_Window_ID
carlos@0
   567
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE
carlos@0
   568
      )
carlos@0
   569
    WHERE EXISTS
carlos@0
   570
      (SELECT *
carlos@0
   571
      FROM AD_WINDOW_TRL t, AD_WF_NODE n
carlos@0
   572
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Window_ID=t.AD_Window_ID
carlos@0
   573
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE AND n.IsCentrallyMaintained='Y' AND n.IsActive='Y'
gorkaion@239
   574
      AND(AD_WF_NODE_TRL.NAME<>t.NAME OR COALESCE(TO_CHAR(AD_WF_NODE_TRL.Description), ' ')<>COALESCE(TO_CHAR(t.Description), ' ')
gorkaion@239
   575
      OR COALESCE(TO_CHAR(AD_WF_NODE_TRL.Help), ' ')<>COALESCE(TO_CHAR(t.Help), ' '))
carlos@0
   576
      )
carlos@0
   577
      ;
carlos@0
   578
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   579
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   580
    -- Workflow Node - Form
carlos@0
   581
    DBMS_OUTPUT.PUT_LINE('Synchronize Workflow Node from Form') ;
carlos@0
   582
    UPDATE AD_WF_NODE
carlos@0
   583
      SET NAME=
carlos@0
   584
      (SELECT f.NAME  FROM AD_FORM f  WHERE f.AD_Form_ID=AD_WF_NODE.AD_Form_ID)
carlos@0
   585
      , Description=
carlos@0
   586
      (SELECT f.Description
carlos@0
   587
      FROM AD_FORM f
carlos@0
   588
      WHERE f.AD_Form_ID=AD_WF_NODE.AD_Form_ID
carlos@0
   589
      )
carlos@0
   590
      , Help=
carlos@0
   591
      (SELECT f.Help  FROM AD_FORM f  WHERE f.AD_Form_ID=AD_WF_NODE.AD_Form_ID)
carlos@0
   592
    WHERE AD_WF_NODE.IsCentrallyMaintained='Y'  AND EXISTS
carlos@0
   593
      (SELECT *
carlos@0
   594
      FROM AD_FORM f
gorkaion@239
   595
      WHERE f.AD_Form_ID=AD_WF_NODE.AD_Form_ID  AND(f.NAME<>AD_WF_NODE.NAME OR COALESCE(TO_CHAR(f.Description), ' ')<>COALESCE(TO_CHAR(AD_WF_NODE.Description), ' ')
gorkaion@239
   596
      OR COALESCE(TO_CHAR(f.Help), ' ')<>COALESCE(TO_CHAR(AD_WF_NODE.Help), ' '))
carlos@0
   597
      )
carlos@0
   598
      ;
carlos@0
   599
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   600
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   601
    -- Workflow Translations - Form
carlos@0
   602
    DBMS_OUTPUT.PUT_LINE('Synchronize Workflow Node Trl from Form Trl') ;
carlos@0
   603
    UPDATE AD_WF_NODE_TRL
carlos@0
   604
      SET NAME=
carlos@0
   605
      (SELECT t.NAME
carlos@0
   606
      FROM AD_FORM_TRL t, AD_WF_NODE n
carlos@0
   607
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Form_ID=t.AD_Form_ID
carlos@0
   608
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE
carlos@0
   609
      )
carlos@0
   610
      , Description=
carlos@0
   611
      (SELECT t.Description
carlos@0
   612
      FROM AD_FORM_TRL t, AD_WF_NODE n
carlos@0
   613
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Form_ID=t.AD_Form_ID
carlos@0
   614
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE
carlos@0
   615
      )
carlos@0
   616
      , Help=
carlos@0
   617
      (SELECT t.Help
carlos@0
   618
      FROM AD_FORM_TRL t, AD_WF_NODE n
carlos@0
   619
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Form_ID=t.AD_Form_ID
carlos@0
   620
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE
carlos@0
   621
      )
carlos@0
   622
    WHERE EXISTS
carlos@0
   623
      (SELECT *
carlos@0
   624
      FROM AD_FORM_TRL t, AD_WF_NODE n
carlos@0
   625
      WHERE AD_WF_NODE_TRL.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Form_ID=t.AD_Form_ID
carlos@0
   626
      AND AD_WF_NODE_TRL.AD_LANGUAGE=t.AD_LANGUAGE AND n.IsCentrallyMaintained='Y' AND n.IsActive='Y'
gorkaion@239
   627
      AND(AD_WF_NODE_TRL.NAME<>t.NAME OR COALESCE(TO_CHAR(AD_WF_NODE_TRL.Description), ' ')<>COALESCE(TO_CHAR(t.Description), ' ')
gorkaion@239
   628
      OR COALESCE(TO_CHAR(AD_WF_NODE_TRL.Help), ' ')<>COALESCE(TO_CHAR(t.Help), ' '))
carlos@0
   629
      )
carlos@0
   630
      ;
carlos@0
   631
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   632
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   633
    DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem Name from Element') ;
carlos@0
   634
    UPDATE AD_PRINTFORMATITEM
carlos@0
   635
      SET NAME=
carlos@0
   636
      (SELECT e.NAME
carlos@0
   637
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   638
      WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
carlos@0
   639
      )
carlos@0
   640
    WHERE EXISTS
carlos@0
   641
      (SELECT *
carlos@0
   642
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   643
      WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
gorkaion@239
   644
      AND e.NAME<>AD_PRINTFORMATITEM.NAME
carlos@0
   645
      )
carlos@0
   646
      AND EXISTS
carlos@0
   647
      (SELECT *
carlos@0
   648
      FROM AD_CLIENT
carlos@0
   649
      WHERE AD_Client_ID=AD_PRINTFORMATITEM.AD_Client_ID AND IsMultiLingualDocument='Y'
carlos@0
   650
      )
carlos@0
   651
      ;
carlos@0
   652
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   653
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   654
    DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem PrintName from Element') ;
carlos@0
   655
    UPDATE AD_PRINTFORMATITEM
carlos@0
   656
      SET PrintName=
carlos@0
   657
      (SELECT e.PrintName
carlos@0
   658
      FROM AD_ELEMENT e, AD_COLUMN c
carlos@0
   659
      WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
carlos@0
   660
      )
carlos@0
   661
    WHERE EXISTS
carlos@0
   662
      (SELECT *
carlos@0
   663
      FROM AD_ELEMENT e, AD_COLUMN c, AD_PRINTFORMAT pf
carlos@0
   664
      WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
gorkaion@239
   665
      AND LENGTH(AD_PRINTFORMATITEM.PrintName)>0  AND e.PrintName<>AD_PRINTFORMATITEM.PrintName
carlos@0
   666
      AND pf.AD_PrintFormat_ID=AD_PRINTFORMATITEM.AD_PrintFormat_ID  AND pf.IsForm='N' AND IsTableBased='Y'
carlos@0
   667
      )
carlos@0
   668
      AND EXISTS
carlos@0
   669
      (SELECT *
carlos@0
   670
      FROM AD_CLIENT
carlos@0
   671
      WHERE AD_Client_ID=AD_PRINTFORMATITEM.AD_Client_ID AND IsMultiLingualDocument='Y'
carlos@0
   672
      )
carlos@0
   673
      ;
carlos@0
   674
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   675
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   676
    DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem Trl from Element Trl (Multi-Lingual)') ;
carlos@0
   677
    UPDATE AD_PRINTFORMATITEM_TRL
carlos@0
   678
      SET PrintName=
carlos@0
   679
      (SELECT e.PrintName
carlos@0
   680
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_PRINTFORMATITEM pfi
carlos@0
   681
      WHERE e.AD_LANGUAGE=AD_PRINTFORMATITEM_TRL.AD_LANGUAGE  AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   682
      AND c.AD_Column_ID=pfi.AD_Column_ID  AND pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
carlos@0
   683
      )
carlos@0
   684
    WHERE EXISTS
carlos@0
   685
      (SELECT *
carlos@0
   686
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_PRINTFORMATITEM pfi, AD_PRINTFORMAT pf
carlos@0
   687
      WHERE e.AD_LANGUAGE=AD_PRINTFORMATITEM_TRL.AD_LANGUAGE  AND e.AD_Element_ID=c.AD_Element_ID
carlos@0
   688
      AND c.AD_Column_ID=pfi.AD_Column_ID  AND pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
gorkaion@239
   689
      AND LENGTH(pfi.PrintName)>0  AND(e.PrintName<>AD_PRINTFORMATITEM_TRL.PrintName OR AD_PRINTFORMATITEM_TRL.PrintName IS NULL)
carlos@0
   690
      AND pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID  AND pf.IsForm='N' AND IsTableBased='Y'
carlos@0
   691
      )
carlos@0
   692
      AND EXISTS
carlos@0
   693
      (SELECT *
carlos@0
   694
      FROM AD_CLIENT
carlos@0
   695
      WHERE AD_Client_ID=AD_PRINTFORMATITEM_TRL.AD_Client_ID AND IsMultiLingualDocument='Y'
carlos@0
   696
      )
carlos@0
   697
      ;
carlos@0
   698
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   699
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   700
    DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem Trl (Not Multi-Lingual)') ;
carlos@0
   701
    UPDATE AD_PRINTFORMATITEM_TRL
carlos@0
   702
      SET PrintName=
carlos@0
   703
      (SELECT pfi.PrintName
carlos@0
   704
      FROM AD_PRINTFORMATITEM pfi
carlos@0
   705
      WHERE pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
carlos@0
   706
      )
carlos@0
   707
    WHERE EXISTS
carlos@0
   708
      (SELECT *
carlos@0
   709
      FROM AD_PRINTFORMATITEM pfi, AD_PRINTFORMAT pf
carlos@0
   710
      WHERE pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
gorkaion@239
   711
      AND LENGTH(pfi.PrintName)>0  AND pfi.PrintName<>AD_PRINTFORMATITEM_TRL.PrintName
carlos@0
   712
      AND pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID  AND pf.IsForm='N' AND pf.IsTableBased='Y'
carlos@0
   713
      )
carlos@0
   714
      AND EXISTS
carlos@0
   715
      (SELECT *
carlos@0
   716
      FROM AD_CLIENT
carlos@0
   717
      WHERE AD_Client_ID=AD_PRINTFORMATITEM_TRL.AD_Client_ID AND IsMultiLingualDocument='N'
carlos@0
   718
      )
carlos@0
   719
      ;
carlos@0
   720
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   721
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   722
    DBMS_OUTPUT.PUT_LINE('Reset PrintFormatItem Trl where not used in base table') ;
carlos@0
   723
    UPDATE AD_PRINTFORMATITEM_TRL
carlos@0
   724
      SET PrintName=NULL
carlos@0
   725
    WHERE PrintName IS NOT NULL  AND EXISTS
carlos@0
   726
      (SELECT *
carlos@0
   727
      FROM AD_PRINTFORMATITEM pfi
carlos@0
   728
      WHERE pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
carlos@0
   729
      AND(LENGTH(pfi.PrintName)=0 OR pfi.PrintName IS NULL)
carlos@0
   730
      )
carlos@0
   731
      ;
carlos@0
   732
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   733
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   734
    /**
carlos@0
   735
    SELECT  e.PrintName "Element", pfi.PrintName "FormatItem", trl.AD_Language, trl.PrintName "Trl"
carlos@0
   736
    FROM  AD_Element e
carlos@0
   737
    INNER JOIN AD_Column c ON (e.AD_Element_ID=c.AD_Element_ID)
carlos@0
   738
    INNER JOIN AD_PrintFormatItem pfi ON (c.AD_Column_ID=pfi.AD_Column_ID)
carlos@0
   739
    INNER JOIN AD_PrintFormatItem_Trl trl ON (pfi.AD_PrintFormatItem_ID=trl.AD_PrintFormatItem_ID)
adrian@170
   740
    WHERE pfi.AD_PrintFormatItem_ID=:1
carlos@0
   741
    **/
carlos@0
   742
    -- Sync Names - Window
carlos@0
   743
    DBMS_OUTPUT.PUT_LINE('Synchronizing Menu with Window') ;
carlos@0
   744
    UPDATE AD_MENU
carlos@0
   745
      SET NAME=
carlos@0
   746
      (SELECT NAME FROM AD_WINDOW w WHERE AD_MENU.AD_Window_ID=w.AD_Window_ID)
carlos@0
   747
      , Description=
carlos@0
   748
      (SELECT Description FROM AD_WINDOW w WHERE AD_MENU.AD_Window_ID=w.AD_Window_ID)
carlos@0
   749
    WHERE AD_Window_ID IS NOT NULL  AND Action='W';
carlos@0
   750
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   751
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   752
    UPDATE AD_MENU_TRL
carlos@0
   753
      SET NAME=
carlos@0
   754
      (SELECT wt.NAME
carlos@0
   755
      FROM AD_WINDOW_TRL wt, AD_MENU m
carlos@0
   756
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Window_ID=wt.AD_Window_ID
carlos@0
   757
      AND AD_MENU_TRL.AD_LANGUAGE=wt.AD_LANGUAGE
carlos@0
   758
      )
carlos@0
   759
      , Description=
carlos@0
   760
      (SELECT wt.Description
carlos@0
   761
      FROM AD_WINDOW_TRL wt, AD_MENU m
carlos@0
   762
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Window_ID=wt.AD_Window_ID
carlos@0
   763
      AND AD_MENU_TRL.AD_LANGUAGE=wt.AD_LANGUAGE
carlos@0
   764
      )
carlos@0
   765
      , IsTranslated=
carlos@0
   766
      (SELECT wt.IsTranslated
carlos@0
   767
      FROM AD_WINDOW_TRL wt, AD_MENU m
carlos@0
   768
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Window_ID=wt.AD_Window_ID
carlos@0
   769
      AND AD_MENU_TRL.AD_LANGUAGE=wt.AD_LANGUAGE
carlos@0
   770
      )
carlos@0
   771
    WHERE EXISTS
carlos@0
   772
      (SELECT *
carlos@0
   773
      FROM AD_WINDOW_TRL wt, AD_MENU m
carlos@0
   774
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Window_ID=wt.AD_Window_ID
carlos@0
   775
      AND AD_MENU_TRL.AD_LANGUAGE=wt.AD_LANGUAGE  AND m.AD_Window_ID IS NOT NULL  AND m.Action='W'
carlos@0
   776
      )
carlos@0
   777
      ;
carlos@0
   778
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   779
    DBMS_OUTPUT.PUT_LINE('  trl rows updated: ' || v_rowcount) ;
carlos@0
   780
    -- Sync Names - Process
carlos@0
   781
    DBMS_OUTPUT.PUT_LINE('Synchronizing Menu with Processes') ;
carlos@0
   782
    UPDATE AD_MENU
carlos@0
   783
      SET NAME=
carlos@0
   784
      (SELECT p.NAME FROM AD_PROCESS p WHERE AD_MENU.AD_Process_ID=p.AD_Process_ID)
carlos@0
   785
      , Description=
carlos@0
   786
      (SELECT p.Description
carlos@0
   787
      FROM AD_PROCESS p
carlos@0
   788
      WHERE AD_MENU.AD_Process_ID=p.AD_Process_ID
carlos@0
   789
      )
carlos@0
   790
    WHERE AD_MENU.AD_Process_ID IS NOT NULL  AND AD_MENU.Action IN('R', 'P') ;
carlos@0
   791
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   792
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   793
    UPDATE AD_MENU_TRL
carlos@0
   794
      SET NAME=
carlos@0
   795
      (SELECT pt.NAME
carlos@0
   796
      FROM AD_PROCESS_TRL pt, AD_MENU m
carlos@0
   797
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Process_ID=pt.AD_Process_ID
carlos@0
   798
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE
carlos@0
   799
      )
carlos@0
   800
      , Description=
carlos@0
   801
      (SELECT pt.Description
carlos@0
   802
      FROM AD_PROCESS_TRL pt, AD_MENU m
carlos@0
   803
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Process_ID=pt.AD_Process_ID
carlos@0
   804
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE
carlos@0
   805
      )
carlos@0
   806
      , IsTranslated=
carlos@0
   807
      (SELECT pt.IsTranslated
carlos@0
   808
      FROM AD_PROCESS_TRL pt, AD_MENU m
carlos@0
   809
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Process_ID=pt.AD_Process_ID
carlos@0
   810
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE
carlos@0
   811
      )
carlos@0
   812
    WHERE EXISTS
carlos@0
   813
      (SELECT *
carlos@0
   814
      FROM AD_PROCESS_TRL pt, AD_MENU m
carlos@0
   815
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Process_ID=pt.AD_Process_ID
carlos@0
   816
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE  AND m.AD_Process_ID IS NOT NULL  AND Action IN('R', 'P')
carlos@0
   817
      );
carlos@0
   818
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   819
    DBMS_OUTPUT.PUT_LINE('  trl rows updated: ' || v_rowcount) ;
carlos@0
   820
    -- Sync Names = Form
carlos@0
   821
    DBMS_OUTPUT.PUT_LINE('Synchronizing Menu with Forms') ;
carlos@0
   822
    UPDATE AD_MENU
carlos@0
   823
      SET NAME=
carlos@0
   824
      (SELECT NAME FROM AD_FORM f WHERE AD_MENU.AD_Form_ID=f.AD_Form_ID)
carlos@0
   825
      , Description=
carlos@0
   826
      (SELECT Description FROM AD_FORM f WHERE AD_MENU.AD_Form_ID=f.AD_Form_ID)
carlos@0
   827
    WHERE AD_Form_ID IS NOT NULL  AND Action='X';
carlos@0
   828
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   829
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   830
    UPDATE AD_MENU_TRL
carlos@0
   831
      SET NAME=
carlos@0
   832
      (SELECT ft.NAME
carlos@0
   833
      FROM AD_FORM_TRL ft, AD_MENU m
carlos@0
   834
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Form_ID=ft.AD_Form_ID
carlos@0
   835
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE
carlos@0
   836
      )
carlos@0
   837
      , Description=
carlos@0
   838
      (SELECT ft.Description
carlos@0
   839
      FROM AD_FORM_TRL ft, AD_MENU m
carlos@0
   840
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Form_ID=ft.AD_Form_ID
carlos@0
   841
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE
carlos@0
   842
      )
carlos@0
   843
      , IsTranslated=
carlos@0
   844
      (SELECT ft.IsTranslated
carlos@0
   845
      FROM AD_FORM_TRL ft, AD_MENU m
carlos@0
   846
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Form_ID=ft.AD_Form_ID
carlos@0
   847
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE
carlos@0
   848
      )
carlos@0
   849
    WHERE EXISTS
carlos@0
   850
      (SELECT *
carlos@0
   851
      FROM AD_FORM_TRL ft, AD_MENU m
carlos@0
   852
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Form_ID=ft.AD_Form_ID
carlos@0
   853
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE  AND m.AD_Form_ID IS NOT NULL  AND Action='X'
carlos@0
   854
      );
carlos@0
   855
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   856
    DBMS_OUTPUT.PUT_LINE('  trl rows updated: ' || v_rowcount) ;
carlos@0
   857
    -- Sync Names - Workflow
carlos@0
   858
    DBMS_OUTPUT.PUT_LINE('Synchronizing Menu with Workflows') ;
carlos@0
   859
    UPDATE AD_MENU
carlos@0
   860
      SET NAME=
carlos@0
   861
      (SELECT p.NAME
carlos@0
   862
      FROM AD_WORKFLOW p
carlos@0
   863
      WHERE AD_MENU.AD_Workflow_ID=p.AD_Workflow_ID
carlos@0
   864
      )
carlos@0
   865
      , Description=
carlos@0
   866
      (SELECT p.Description
carlos@0
   867
      FROM AD_WORKFLOW p
carlos@0
   868
      WHERE AD_MENU.AD_Workflow_ID=p.AD_Workflow_ID
carlos@0
   869
      )
carlos@0
   870
    WHERE AD_MENU.AD_Workflow_ID IS NOT NULL  AND AD_MENU.Action='F';
carlos@0
   871
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   872
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   873
    UPDATE AD_MENU_TRL
carlos@0
   874
      SET NAME=
carlos@0
   875
      (SELECT pt.NAME
carlos@0
   876
      FROM AD_WORKFLOW_TRL pt, AD_MENU m
carlos@0
   877
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Workflow_ID=pt.AD_Workflow_ID
carlos@0
   878
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE
carlos@0
   879
      )
carlos@0
   880
      , Description=
carlos@0
   881
      (SELECT pt.Description
carlos@0
   882
      FROM AD_WORKFLOW_TRL pt, AD_MENU m
carlos@0
   883
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Workflow_ID=pt.AD_Workflow_ID
carlos@0
   884
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE
carlos@0
   885
      )
carlos@0
   886
      , IsTranslated=
carlos@0
   887
      (SELECT pt.IsTranslated
carlos@0
   888
      FROM AD_WORKFLOW_TRL pt, AD_MENU m
carlos@0
   889
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Workflow_ID=pt.AD_Workflow_ID
carlos@0
   890
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE
carlos@0
   891
      )
carlos@0
   892
    WHERE EXISTS
carlos@0
   893
      (SELECT *
carlos@0
   894
      FROM AD_WORKFLOW_TRL pt, AD_MENU m
carlos@0
   895
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Workflow_ID=pt.AD_Workflow_ID
carlos@0
   896
      AND AD_MENU_TRL.AD_LANGUAGE=pt.AD_LANGUAGE  AND m.AD_Workflow_ID IS NOT NULL  AND Action='F'
carlos@0
   897
      )
carlos@0
   898
      ;
carlos@0
   899
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   900
    DBMS_OUTPUT.PUT_LINE('  trl rows updated: ' || v_rowcount) ;
carlos@0
   901
    -- Sync Names = Task
carlos@0
   902
    DBMS_OUTPUT.PUT_LINE('Synchronizing Menu with Tasks') ;
carlos@0
   903
    UPDATE AD_MENU
carlos@0
   904
      SET NAME=
carlos@0
   905
      (SELECT NAME FROM AD_TASK f WHERE AD_MENU.AD_Task_ID=f.AD_Task_ID)
carlos@0
   906
      , Description=
carlos@0
   907
      (SELECT Description FROM AD_TASK f WHERE AD_MENU.AD_Task_ID=f.AD_Task_ID)
carlos@0
   908
    WHERE AD_Task_ID IS NOT NULL  AND Action='T';
carlos@0
   909
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   910
    DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
carlos@0
   911
    UPDATE AD_MENU_TRL
carlos@0
   912
      SET NAME=
carlos@0
   913
      (SELECT ft.NAME
carlos@0
   914
      FROM AD_TASK_TRL ft, AD_MENU m
carlos@0
   915
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Task_ID=ft.AD_Task_ID
carlos@0
   916
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE
carlos@0
   917
      )
carlos@0
   918
      , Description=
carlos@0
   919
      (SELECT ft.Description
carlos@0
   920
      FROM AD_TASK_TRL ft, AD_MENU m
carlos@0
   921
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Task_ID=ft.AD_Task_ID
carlos@0
   922
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE
carlos@0
   923
      )
carlos@0
   924
      , IsTranslated=
carlos@0
   925
      (SELECT ft.IsTranslated
carlos@0
   926
      FROM AD_TASK_TRL ft, AD_MENU m
carlos@0
   927
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Task_ID=ft.AD_Task_ID
carlos@0
   928
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE
carlos@0
   929
      )
carlos@0
   930
    WHERE EXISTS
carlos@0
   931
      (SELECT *
carlos@0
   932
      FROM AD_TASK_TRL ft, AD_MENU m
carlos@0
   933
      WHERE AD_MENU_TRL.AD_Menu_ID=m.AD_Menu_ID AND m.AD_Task_ID=ft.AD_Task_ID
carlos@0
   934
      AND AD_MENU_TRL.AD_LANGUAGE=ft.AD_LANGUAGE  AND m.AD_Task_ID IS NOT NULL  AND Action='T'
carlos@0
   935
      )
carlos@0
   936
      ;
carlos@0
   937
    v_rowcount:=SQL%ROWCOUNT;
carlos@0
   938
    DBMS_OUTPUT.PUT_LINE('  trl rows updated: ' || v_rowcount) ;
gorkaion@239
   939
    --<<FINISH_PROCESS>>
carlos@0
   940
    IF(p_PInstance_ID IS NOT NULL) THEN
carlos@0
   941
      --  Update AD_PInstance
carlos@0
   942
      DBMS_OUTPUT.PUT_LINE('Updating PInstance - Finished ' || v_Message) ;
carlos@0
   943
      Ad_Update_Pinstance(p_PInstance_ID, NULL, 'N', v_Result, v_Message) ;
carlos@0
   944
    END IF;
carlos@0
   945
    RETURN;
carlos@0
   946
  END; --BODY
carlos@0
   947
EXCEPTION
carlos@0
   948
WHEN OTHERS THEN
carlos@0
   949
  v_ResultStr:= '@ERROR=' || SQLERRM;
carlos@0
   950
  DBMS_OUTPUT.PUT_LINE(v_ResultStr) ;
carlos@0
   951
  ROLLBACK;
carlos@0
   952
  IF(p_PInstance_ID IS NOT NULL) THEN
carlos@0
   953
    Ad_Update_Pinstance(p_PInstance_ID, NULL, 'N', 0, v_ResultStr) ;
carlos@0
   954
  END IF;
carlos@0
   955
  RETURN;
adrian@94
   956
END Ad_Synchronize
adrian@170
   957
gorkaion@239
   958
gorkaion@239
   959
]]></body>
adrian@94
   960
    </function>
adrian@94
   961
  </database>