src-db/database/model/functions/AD_SYNCHRONIZE.xml
changeset 799 fef2c5e2feb7
parent 785 8dba91261590
child 1576 bb3c7a88250a
equal deleted inserted replaced
798:4994e5a604bb 799:fef2c5e2feb7
   632       OR COALESCE(TO_CHAR(AD_WF_NODE_TRL.Help), ' ')<>COALESCE(TO_CHAR(t.Help), ' '))
   632       OR COALESCE(TO_CHAR(AD_WF_NODE_TRL.Help), ' ')<>COALESCE(TO_CHAR(t.Help), ' '))
   633       )
   633       )
   634       ;
   634       ;
   635     v_rowcount:=SQL%ROWCOUNT;
   635     v_rowcount:=SQL%ROWCOUNT;
   636     DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
   636     DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
   637     DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem Name from Element') ;
   637     
   638     UPDATE AD_PRINTFORMATITEM
       
   639       SET NAME=
       
   640       (SELECT e.NAME
       
   641       FROM AD_ELEMENT e, AD_COLUMN c
       
   642       WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
       
   643       )
       
   644     WHERE EXISTS
       
   645       (SELECT *
       
   646       FROM AD_ELEMENT e, AD_COLUMN c
       
   647       WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
       
   648       AND e.NAME<>AD_PRINTFORMATITEM.NAME
       
   649       )
       
   650       AND EXISTS
       
   651       (SELECT *
       
   652       FROM AD_CLIENT
       
   653       WHERE AD_Client_ID=AD_PRINTFORMATITEM.AD_Client_ID AND IsMultiLingualDocument='Y'
       
   654       )
       
   655       ;
       
   656     v_rowcount:=SQL%ROWCOUNT;
       
   657     DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
       
   658     DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem PrintName from Element') ;
       
   659     UPDATE AD_PRINTFORMATITEM
       
   660       SET PrintName=
       
   661       (SELECT e.PrintName
       
   662       FROM AD_ELEMENT e, AD_COLUMN c
       
   663       WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
       
   664       )
       
   665     WHERE EXISTS
       
   666       (SELECT *
       
   667       FROM AD_ELEMENT e, AD_COLUMN c, AD_PRINTFORMAT pf
       
   668       WHERE e.AD_Element_ID=c.AD_Element_ID  AND c.AD_Column_ID=AD_PRINTFORMATITEM.AD_Column_ID
       
   669       AND LENGTH(AD_PRINTFORMATITEM.PrintName)>0  AND e.PrintName<>AD_PRINTFORMATITEM.PrintName
       
   670       AND pf.AD_PrintFormat_ID=AD_PRINTFORMATITEM.AD_PrintFormat_ID  AND pf.IsForm='N' AND IsTableBased='Y'
       
   671       )
       
   672       AND EXISTS
       
   673       (SELECT *
       
   674       FROM AD_CLIENT
       
   675       WHERE AD_Client_ID=AD_PRINTFORMATITEM.AD_Client_ID AND IsMultiLingualDocument='Y'
       
   676       )
       
   677       ;
       
   678     v_rowcount:=SQL%ROWCOUNT;
       
   679     DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
       
   680     DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem Trl from Element Trl (Multi-Lingual)') ;
       
   681     UPDATE AD_PRINTFORMATITEM_TRL
       
   682       SET PrintName=
       
   683       (SELECT e.PrintName
       
   684       FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_PRINTFORMATITEM pfi
       
   685       WHERE e.AD_LANGUAGE=AD_PRINTFORMATITEM_TRL.AD_LANGUAGE  AND e.AD_Element_ID=c.AD_Element_ID
       
   686       AND c.AD_Column_ID=pfi.AD_Column_ID  AND pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
       
   687       )
       
   688     WHERE EXISTS
       
   689       (SELECT *
       
   690       FROM AD_ELEMENT_TRL e, AD_COLUMN c, AD_PRINTFORMATITEM pfi, AD_PRINTFORMAT pf
       
   691       WHERE e.AD_LANGUAGE=AD_PRINTFORMATITEM_TRL.AD_LANGUAGE  AND e.AD_Element_ID=c.AD_Element_ID
       
   692       AND c.AD_Column_ID=pfi.AD_Column_ID  AND pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
       
   693       AND LENGTH(pfi.PrintName)>0  AND(e.PrintName<>AD_PRINTFORMATITEM_TRL.PrintName OR AD_PRINTFORMATITEM_TRL.PrintName IS NULL)
       
   694       AND pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID  AND pf.IsForm='N' AND IsTableBased='Y'
       
   695       )
       
   696       AND EXISTS
       
   697       (SELECT *
       
   698       FROM AD_CLIENT
       
   699       WHERE AD_Client_ID=AD_PRINTFORMATITEM_TRL.AD_Client_ID AND IsMultiLingualDocument='Y'
       
   700       )
       
   701       ;
       
   702     v_rowcount:=SQL%ROWCOUNT;
       
   703     DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
       
   704     DBMS_OUTPUT.PUT_LINE('Synchronize PrintFormatItem Trl (Not Multi-Lingual)') ;
       
   705     UPDATE AD_PRINTFORMATITEM_TRL
       
   706       SET PrintName=
       
   707       (SELECT pfi.PrintName
       
   708       FROM AD_PRINTFORMATITEM pfi
       
   709       WHERE pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
       
   710       )
       
   711     WHERE EXISTS
       
   712       (SELECT *
       
   713       FROM AD_PRINTFORMATITEM pfi, AD_PRINTFORMAT pf
       
   714       WHERE pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
       
   715       AND LENGTH(pfi.PrintName)>0  AND pfi.PrintName<>AD_PRINTFORMATITEM_TRL.PrintName
       
   716       AND pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID  AND pf.IsForm='N' AND pf.IsTableBased='Y'
       
   717       )
       
   718       AND EXISTS
       
   719       (SELECT *
       
   720       FROM AD_CLIENT
       
   721       WHERE AD_Client_ID=AD_PRINTFORMATITEM_TRL.AD_Client_ID AND IsMultiLingualDocument='N'
       
   722       )
       
   723       ;
       
   724     v_rowcount:=SQL%ROWCOUNT;
       
   725     DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
       
   726     DBMS_OUTPUT.PUT_LINE('Reset PrintFormatItem Trl where not used in base table') ;
       
   727     UPDATE AD_PRINTFORMATITEM_TRL
       
   728       SET PrintName=NULL
       
   729     WHERE PrintName IS NOT NULL  AND EXISTS
       
   730       (SELECT *
       
   731       FROM AD_PRINTFORMATITEM pfi
       
   732       WHERE pfi.AD_PrintFormatItem_ID=AD_PRINTFORMATITEM_TRL.AD_PrintFormatItem_ID
       
   733       AND(LENGTH(pfi.PrintName)=0 OR pfi.PrintName IS NULL)
       
   734       )
       
   735       ;
       
   736     v_rowcount:=SQL%ROWCOUNT;
       
   737     DBMS_OUTPUT.PUT_LINE('  rows updated: ' || v_rowcount) ;
       
   738     /**
       
   739     SELECT  e.PrintName "Element", pfi.PrintName "FormatItem", trl.AD_Language, trl.PrintName "Trl"
       
   740     FROM  AD_Element e
       
   741     INNER JOIN AD_Column c ON (e.AD_Element_ID=c.AD_Element_ID)
       
   742     INNER JOIN AD_PrintFormatItem pfi ON (c.AD_Column_ID=pfi.AD_Column_ID)
       
   743     INNER JOIN AD_PrintFormatItem_Trl trl ON (pfi.AD_PrintFormatItem_ID=trl.AD_PrintFormatItem_ID)
       
   744     WHERE pfi.AD_PrintFormatItem_ID=:1
       
   745     **/
       
   746     -- Sync Names - Window
   638     -- Sync Names - Window
   747     DBMS_OUTPUT.PUT_LINE('Synchronizing Menu with Window') ;
   639     DBMS_OUTPUT.PUT_LINE('Synchronizing Menu with Window') ;
   748     UPDATE AD_MENU
   640     UPDATE AD_MENU
   749       SET NAME=
   641       SET NAME=
   750       (SELECT NAME FROM AD_WINDOW w WHERE AD_MENU.AD_Window_ID=w.AD_Window_ID)
   642       (SELECT NAME FROM AD_WINDOW w WHERE AD_MENU.AD_Window_ID=w.AD_Window_ID)