fix old mxik




    The code updates the document product's catalog code and states.

    update sm_seller_products
    set identification_code= :new_mxik
    where id in (select product_id from sm_document_products where document_id = :document_id and catalog_code = :old_mxik);
    update sm_document_products
    set catalog_code = :new_mxik
    where id in (select as p_id
      from sm_document_products dp
        left join sm_document_contracts dc on dp.document_id =
        left join sm_document_facturas df on dp.document_id =
      where dp.catalog_code = :old_mxik
        and (( = :document_id and dc.state = 1 and
        (dc.doc_status is null or dc.doc_status in ('CREATED'))) or
        ( = :document_id and df.state = 1 and (df.doc_status is null or df.doc_status in ('CREATED'))))
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.