Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 2.50 KB | None | 0 0
  1. SELECT WIP_DJ.wip_entity_id,
  2.       wip_dj.lot_number INPUT_LOT,
  3.       WIP_DJ.organization_id,
  4.       WIP_DJ.date_released,
  5.       WIP_DJ.last_update_date,
  6.       WIP_DJ.start_quantity,
  7.       WE.wip_entity_name,
  8.       WIP_DJ.common_routing_sequence_id,
  9.       wo.operation_seq_num,
  10.      bop.operation_code
  11. FROM   --mtl_lot_numbers MTLL,
  12.       wip.wip_discrete_jobs WIP_DJ,
  13.       wip_entities WE,
  14.     --  mtl_object_genealogy GEN,
  15.       wip_operations WO,
  16.       bom_standard_operations bop
  17. WHERE  WIP_DJ.wip_entity_id = WE.wip_entity_id
  18.       AND WIP_DJ.organization_id = WE.organization_id
  19.        AND WIP_DJ.PRIMARY_ITEM_ID = WE.PRIMARY_ITEM_ID
  20.      -- AND WE.gen_object_id = GEN.parent_object_id
  21.     --  AND (WIP_DJ.last_update_date BETWEEN To_date (:last_run, 'YYYY-MM-DD HH24:MI:SS') AND
  22.     --                                   To_date (:now, 'YYYY-MM-DD HH24:MI:SS') )
  23.     --  AND GEN.object_id = MTLL.gen_object_id
  24.     --  AND mtll.organization_id = wip_dj.organization_id
  25.       AND wo.organization_id = we.organization_id
  26.       AND wo.wip_entity_id  = we.wip_entity_id
  27.       AND bop.standard_operation_id = wo.standard_operation_id
  28.      -- and we.wip_entity_name = 'ERT4'
  29.       --AND WIP_DJ.organization_id = :orgid
  30. UNION
  31. SELECT srj.wip_entity_id,
  32.       NVL(ssj.wip_entity_name,wip_dj.lot_number) INPUT_LOT,
  33.       srj.organization_id,
  34.       WIP_DJ.date_released,
  35.       WIP_DJ.last_update_date,
  36.       srj.start_quantity,
  37.       srj.wip_entity_name,
  38.       srj.common_routing_sequence_id,
  39.       wo.operation_seq_num,
  40.      bop.operation_code
  41. FROM  wip_operations WO,
  42.       bom_standard_operations bop,
  43.       wsm_sm_starting_jobs ssj,
  44.       wsm_sm_resulting_jobs srj,
  45.       wip_discrete_jobs wip_dj,
  46.       wip_entities we
  47. WHERE  
  48.     --  AND (WIP_DJ.last_update_date BETWEEN To_date (:last_run, 'YYYY-MM-DD HH24:MI:SS') AND
  49.     --                                   To_date (:now, 'YYYY-MM-DD HH24:MI:SS') )
  50.        srj.transaction_id = (SELECT MAX(transaction_id) FROM wsm_sm_resulting_jobs srj2 WHERE srj2.wip_entity_id = WIP_DJ.wip_entity_id)
  51.       AND ssj.transaction_id = srj.transaction_id
  52.       AND ssj.wip_entity_id = srj.wip_entity_id
  53.       AND wo.organization_id = srj.organization_id
  54.       AND wo.wip_entity_id  = srj.wip_entity_id
  55.       AND bop.standard_operation_id = wo.standard_operation_id
  56.       AND WIP_DJ.wip_entity_id = srj.wip_entity_id
  57.       AND WIP_DJ.organization_id = srj.organization_id
  58.       AND WIP_DJ.wip_entity_id = WE.wip_entity_id
  59.     --  --AND WIP_DJ.organization_id = :orgid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement