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