From b3948e1d1ce567e4c964af374a3a58abdaf3fca1 Mon Sep 17 00:00:00 2001 From: tspc Date: Mon, 1 Dec 2008 09:51:42 +0000 Subject: [PATCH] BF1936311 Migration of existing BOM to Libero BOM - Migrate BOMType to ComponentType and Feature fields --- .../335_BF1936311_migrate_bomtype.sql | 29 +++++++++++++++ .../335_BF1936311_migrate_bomtype.sql | 35 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 migration/352a-trunk/335_BF1936311_migrate_bomtype.sql create mode 100644 migration/352a-trunk/postgresql/335_BF1936311_migrate_bomtype.sql diff --git a/migration/352a-trunk/335_BF1936311_migrate_bomtype.sql b/migration/352a-trunk/335_BF1936311_migrate_bomtype.sql new file mode 100644 index 0000000000..317badf44f --- /dev/null +++ b/migration/352a-trunk/335_BF1936311_migrate_bomtype.sql @@ -0,0 +1,29 @@ +update pp_product_bomline pbl +set (componenttype, feature) = + (select (case + when mbl.bomtype = 'O' then 'OP' + when mbl.bomtype in ('1','2','3','4','5','6','7','8','9') then 'VA' + else 'CO' + end), + (case + when mbl.bomtype in ('1','2','3','4','5','6','7','8','9') + then (select name + from ad_ref_list + where ad_reference_id = 279 + and value = mbl.bomtype) + else null + end) + from m_product_bom mbl, pp_product_bom pb, pp_product_bomline pbl2 + where pbl2.pp_product_bomline_id = pbl.pp_product_bomline_id + and pb.m_product_id = mbl.m_product_id + and pbl2.pp_product_bom_id = pb.pp_product_bom_id + and mbl.m_productbom_id = pbl2.m_product_id) +where exists + (select * + from m_product_bom mbl, pp_product_bom pb, pp_product_bomline pbl2 + where (mbl.bomtype <> 'P' or pbl2.componenttype <> 'CO') + and pbl2.pp_product_bomline_id = pbl.pp_product_bomline_id + and pb.m_product_id = mbl.m_product_id + and pbl2.pp_product_bom_id = pb.pp_product_bom_id + and mbl.m_productbom_id = pbl2.m_product_id) +; diff --git a/migration/352a-trunk/postgresql/335_BF1936311_migrate_bomtype.sql b/migration/352a-trunk/postgresql/335_BF1936311_migrate_bomtype.sql new file mode 100644 index 0000000000..97b98b5994 --- /dev/null +++ b/migration/352a-trunk/postgresql/335_BF1936311_migrate_bomtype.sql @@ -0,0 +1,35 @@ +update pp_product_bomline pbl +set componenttype = + (select (case + when mbl.bomtype = 'O' then 'OP' + when mbl.bomtype in ('1','2','3','4','5','6','7','8','9') then 'VA' + else 'CO' + end) + from m_product_bom mbl, pp_product_bom pb, pp_product_bomline pbl2 + where pbl2.pp_product_bomline_id = pbl.pp_product_bomline_id + and pb.m_product_id = mbl.m_product_id + and pbl2.pp_product_bom_id = pb.pp_product_bom_id + and mbl.m_productbom_id = pbl2.m_product_id) , + feature = + (select (case + when mbl.bomtype in ('1','2','3','4','5','6','7','8','9') + then (select name + from ad_ref_list + where ad_reference_id = 279 + and value = mbl.bomtype) + else null + end) + from m_product_bom mbl, pp_product_bom pb, pp_product_bomline pbl2 + where pbl2.pp_product_bomline_id = pbl.pp_product_bomline_id + and pb.m_product_id = mbl.m_product_id + and pbl2.pp_product_bom_id = pb.pp_product_bom_id + and mbl.m_productbom_id = pbl2.m_product_id) +where exists + (select * + from m_product_bom mbl, pp_product_bom pb, pp_product_bomline pbl2 + where (mbl.bomtype <> 'P' or pbl2.componenttype <> 'CO') + and pbl2.pp_product_bomline_id = pbl.pp_product_bomline_id + and pb.m_product_id = mbl.m_product_id + and pbl2.pp_product_bom_id = pb.pp_product_bom_id + and mbl.m_productbom_id = pbl2.m_product_id) +;