DimitarVasilev

Untitled

Jul 20th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 6.49 KB | None | 0 0
  1. --3  
  2. --fromDate -> Fri Jun 23 00:00:00 CEST 2017
  3. --toDate -> Mon Jun 26 23:59:00 CEST 2017
  4. --language -> FR
  5. --poiName -> 577147
  6. --personCategory -> -1
  7. --personName -> -1
  8. --voGroup : [-1]
  9. --TIN -> -1
  10. --status -> -1
  11. --showAllPpl -> N
  12. --gu_user_id -> 102298
  13.    
  14. SELECT DISTINCT        (Person.PERSON_ID) p_id,
  15.                         TOUSERDATE(SocialOfficeTransaction.work_date, OperationCenter.timezone) WORK_DATE,
  16.                         SocialOfficeTransaction.SOCIAL_OFFICE_TRANSACTION_ID,
  17.                         SocialOfficeTransaction.POI_TIN,
  18.                         SocialOfficeTransaction.WBS_ID,
  19.                         P_PERSON.getCawCategoryName(Person.PERSON_ID) AS person_category,
  20.                         SocialOfficeTransaction.WORK_DATE,
  21.                         SocialOfficeTransaction.WBS_NAME AS WBS_NAME,
  22.                         SocialOfficeTransaction.SO_TRANSACTION_STATUS_NAME AS SO_TRANSACTION_STATUS_NAME,
  23.                         SocialOfficeTransaction.SO_TRANSACTION_STATUS_ID,
  24.                         SocialOfficeTransaction.CREATION_DATE,
  25.                         SocialOfficeTransaction.CREATION_USER_NAME,
  26.                         SocialOfficeTransaction.SO_CREATION_NUMBER,
  27.                         SocialOfficeTransaction.CANCEL_DATE,
  28.                         SocialOfficeTransaction.CANCELLATION_USER_NAME,
  29.                         SocialOfficeTransaction.SO_CANCELLATION_NUMBER,
  30.                         SocialOfficeTransaction.SO_COMMENT,
  31.                         Person.COMPANY_NR,
  32.                         SocialOfficeTransaction.plan_mode,
  33.                         Person.FIRST_NAME,
  34.                         Person.LAST_NAME,
  35.                         SocialOfficeTransaction.CREATION_GUI_USER_ID,
  36.                         SocialOfficeTransaction.CANCELLATION_GUI_USER_ID,
  37.                         SocialOfficeTransaction.PERSON_DATA_ID,
  38.                         SocialOfficeTransaction.PERSON_ID AS PERSON_ID1,
  39.                         SocialOfficeTransaction.SO_TRANSACTION_STATUS_ID AS SO_TRANSACTION_STATUS_ID1,
  40.                         SocialOfficeTransaction.WBS_ID AS WBS_ID1,
  41.                         SocialOfficeTransaction.POI_ID,
  42.                         TO_CHAR(SocialOfficeTransaction.WORK_DATE, 'Dy') AS VIEW_ATTR,
  43.                         TO_CHAR(SocialOfficeTransaction.WORK_DATE, 'dd') AS VIEW_ATTR,
  44.                         SocialOfficeTransaction.NAME,
  45.                         TOUSERDATE(SocialOfficeTransaction.work_date,  OperationCenter.timezone) AS VIEW_ATTR2,
  46.                         SocialOfficeTransaction.REF_NUMBER,
  47.                         TOUSERDATE(SocialOfficeTransaction.CREATION_DATE,                   OPERATIONCENTER.timezone) AS VIEW_ATTR3,
  48.                         TOUSERDATE(SocialOfficeTransaction.CANCEL_DATE,                     OPERATIONCENTER.timezone) AS VIEW_ATTR4
  49.           FROM
  50.                (SELECT SocialOfficeTransaction.*, OcPoi.NAME NAME, Wbs.REF_NUMBER, Wbs.NAME AS WBS_NAME, Wbs.POI_TIN WBS_POI_TIN, Wbs.POI_ID, SoTransactionStatus.NAME AS SO_TRANSACTION_STATUS_NAME
  51.                FROM SOCIAL_OFFICE_TRANSACTION SocialOfficeTransaction, GUI_USERS GuiUsers, OPERATION_CENTER OperationCenter,
  52.                SO_TRANSACTION_STATUS     SoTransactionStatus,
  53.                WBS                                Wbs,
  54.                OC_POI                             OcPoi,
  55.                PERSON                             Person,
  56.                GU_PERSON                          GuPerson
  57.                WHERE GuiUsers.gui_user_id = 102298
  58.                AND SocialOfficeTransaction.PERSON_ID = Person.PERSON_ID
  59.                AND Person.PERSON_ID = GuPerson.person_id
  60.                AND GuPerson.gui_user_id =  GuiUsers.gui_user_id
  61.                AND SocialOfficeTransaction.SO_TRANSACTION_STATUS_ID =  SoTransactionStatus.SO_TRANSACTION_STATUS_ID
  62.                AND SocialOfficeTransaction.WBS_ID  = Wbs.WBS_ID
  63.                AND GuiUsers.Operation_Center_Id = OperationCenter.operation_center_id
  64.                AND Wbs.POI_ID = OcPoi.POI_ID
  65.                AND ((OcPoi.OC_POI_STATUS_ID = 0 AND SocialOfficeTransaction.so_transaction_status_id = 7) OR (SocialOfficeTransaction.so_transaction_status_id <> 7))
  66.                AND nvl (TOUSERDATE(SocialOfficeTransaction.work_date,  OperationCenter.timezone),  toutcdate( to_date ('23/06/2017 00:00','dd/MM/yyyy HH24:mi') , OperationCenter.timezone )) >= toutcdate( to_date ('23/06/2017 00:00','dd/MM/yyyy HH24:mi') , OperationCenter.timezone )
  67.                AND nvl(TOUSERDATE(SocialOfficeTransaction.work_date, OperationCenter.timezone), toutcdate( to_date ('26/06/2017 23:59','dd/MM/yyyy HH24:mi') , OperationCenter.timezone )) <toutcdate( to_date ('26/06/2017 23:59','dd/MM/yyyy HH24:mi') , OperationCenter.timezone ) +1
  68.                AND nvl( SocialOfficeTransaction.SO_TRANSACTION_STATUS_ID, 2) =  nvl( decode(-1, -1, SocialOfficeTransaction.SO_TRANSACTION_STATUS_ID,  -1), 2)
  69.                AND nvl(Wbs.poi_id, -2)  =   nvl (decode(577147, -1,  Wbs.poi_id, 577147), -2)
  70.                AND nvl(  SocialOfficeTransaction.POI_TIN, -2) = nvl( decode('-1', '-1',   SocialOfficeTransaction.POI_TIN, '-1') , -2)
  71.                ) SocialOfficeTransaction,
  72.                PERSON                             Person,
  73.                GUI_USERS                          GuiUsers,
  74.                OPERATION_CENTER                   OperationCenter,
  75.                GU_PERSON                          GuPerson,
  76.                vo_group_person                    vgp
  77.          WHERE SocialOfficeTransaction.PERSON_ID (+) = Person.PERSON_ID
  78.            AND ( 'N'= 'Y'  OR SocialOfficeTransaction.person_id IS NOT NULL)
  79.            AND Person.PERSON_ID = GuPerson.person_id
  80.            AND GuPerson.gui_user_id =  102298
  81.            AND GuiUsers.gui_user_id = GuPerson.gui_user_id
  82.            AND GuiUsers.Operation_Center_Id = OperationCenter.operation_center_id
  83.            AND Person.person_id = vgp.person_id(+)    
  84.            AND Person.person_status_id = 0
  85.            AND Person.PERSON_ID = decode(-1, -1, Person.PERSON_ID, -1)
  86.            AND ((-1 IN -1) OR  (Person.PERSON_ID IN (SELECT person_id FROM vo_group_person WHERE vo_group_id IN -1)))
  87.            AND Person.vo_person_category_id =       decode(-1,  -1,   Person.vo_person_category_id,  -1)
  88.            AND UPPER(gu.LANGUAGE) LIKE 'FR'
  89.          ORDER BY P_PERSON.getCawCategoryName(Person.PERSON_ID),
  90.                   SocialOfficeTransaction.WORK_DATE,
  91.                   Person.LAST_NAME,
  92.                   Person.FIRST_NAME,
  93.                   Person.COMPANY_NR,
  94.                   NAME;
Add Comment
Please, Sign In to add comment