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