/* TC BOMView Precice  New:06.07.14 L.Up 11.08.17 */
SELECT
  i.puid         AS BOML_i_puid,
  i.pitem_id     AS BOML_pitem_id,
  ir.puid        AS BOML_ir_puid,
  ir.pitem_revision_id AS BOML_pitem_revision_id,
  bo.pseq_no     AS BOML_pseq_no,
  bo.puid        AS BOML_puid,
  bo.rnotes_refu AS BOML_OcN_ptt_puid,
  bvr.pstruct_last_mod_date AS BOMV_pstruct_last_mod_date,
  bvr.puid AS BOMV_puid,
  
  cast(bo.pqty_value as NUMBER(*,28)) AS BOML_qty_val,  
  cast(bo.pext_transform_rot00 as NUMBER(*,28))  AS BOML_trf_rot00,
  cast(bo.pext_transform_rot01 as NUMBER(*,28))  AS BOML_trf_rot01,
  cast(bo.pext_transform_rot02 as NUMBER(*,28))  AS BOML_trf_rot02,
  cast(bo.pext_transform_rot10 as NUMBER(*,28))  AS BOML_trf_rot10,  
  cast(bo.pext_transform_rot11 as NUMBER(*,28))  AS BOML_trf_rot11,
  cast(bo.pext_transform_rot12 as NUMBER(*,28))  AS BOML_trf_rot12,
  cast(bo.pext_transform_rot20 as NUMBER(*,28))  AS BOML_trf_rot20,
  cast(bo.pext_transform_rot21 as NUMBER(*,28))  AS BOML_trf_rot21, 
  cast(bo.pext_transform_rot22 as NUMBER(*,28))  AS BOML_trf_rot22,
  cast(bo.pext_transform_per0  as NUMBER(*,28))  AS BOML_trf_per0,
  cast(bo.pext_transform_per1  as NUMBER(*,28))  AS BOML_trf_per1,
  cast(bo.pext_transform_per2  as NUMBER(*,28))  AS BOML_trf_per2,
  cast(bo.pext_transform_tra0  as NUMBER(*,28))  AS BOML_trf_tra0,
  cast(bo.pext_transform_tra1  as NUMBER(*,28))  AS BOML_trf_tra1,
  cast(bo.pext_transform_tra2  as NUMBER(*,28))  AS BOML_trf_tra2,
  cast(bo.pext_transform_invscale  as NUMBER(*,28)) AS BOML_trf_invscale,  
  bo.pref_designator      AS BOML_ref_designator,
  bo.rchild_itemu         AS BOML_child_itemu,
  bo.rchild_itemc         AS BOML_child_itemc,
  bo.poccurrence_name     AS BOML_occurre_name,
  bo.poccurrence_type     AS BOML_occurre_type,
  bo.porder_no            AS BOML_order_no
  
  
FROM
 infodba.POM_BACKPOINTER bp
 INNER JOIN infodba.PPSBOMVIEWREVISION bvr ON (bvr.puid = bp.to_uid)
 INNER JOIN infodba.PPSOCCURRENCE bo ON (bo.rparent_bvru = bvr.puid)
 INNER JOIN infodba.PITEMREVISION ir ON (ir.puid = bo.rchild_itemu)
 INNER JOIN infodba.PITEM i ON (i.puid = ir.ritems_tagu)

 LEFT JOIN infodba.PPSBOMVIEW bv on (bvr.rbom_viewu = bv.puid)
 LEFT JOIN infodba.PPSVIEWTYPE bvt on (bvt.puid = bv.rview_typeu)
WHERE
 bp.from_uid = :para_ir_puid
 AND upper(bvt.pname) in ('VIEW', 'CATIA_MULTI_MODEL', 'CATIA')
