MYSQL更新触发器

时间:2019-07-19 17:50:31

标签: mysql triggers

我有一个更新查询,我想在另一个表上运行。问题在于,传入的更新查询可以具有不同数量的要更新的列,因此我无法指出要更新的确切列。

update eamglo5_billingsystem.consignment 
    set id = new.id,
    consignment_status = new.consignment_status,
    account = new.account,
    awb = new.awb,
    dhl_awb = new.dhl_awb,
    hawb = new.hawb,
    service = new.service,
    handling = new.handling,
    reference = new.reference,
    printed_file_id = new.printed_file_id,
    date_submitted = new.date_submitted,
    date_imported = new.date_imported,
    date_printed = new.date_printed,
    date_printed = new.date_printed,
    date_booked = new.date_booked,
    booked_file_id = new.booked_file_id,
    date_exported = new.date_exported,
    company = new.company,
    contact = new.contact,
    address_line_1 = new.address_line_1,
    address_line_2 = new.address_line_2,
    address_line_3 = new.address_line_3,
    city = new.city,
    country = new.country,
    country_iso_code = new.country_iso_code,
    postcode = new.postcode,
    telephone = new.telephone,
    number_pieces = new.number_pieces,
    weight = new.weight,
    hv_lv = new.hv_lv,
    description = new.description,
    value = new.value,
    currency = new.currency,
    notes = new.notes,
    routing_code = new.routing_code,
    flight_number = new.flight_number,
    bag_number = new.bag_number,
    remote_area_charge = new.remote_area_charge,
    manifest_id = new.manifest_id,
    sender_name = new.sender_name,
    duty_paid = new.duty_paid,
    create_awb = new.create_awb,
    shipper_company = new.shipper_company,
    shipper_contact_person = new.shipper_contact_person,
    shipper_address_line1 = new.shipper_address_line1,
    shipper_address_line2 = new.shipper_address_line2,
    shipper_address_line3 = new.shipper_address_line3,
    shipper_city = new.shipper_city,
    shipper_country = new.shipper_country,
    shipper_postcode = new.shipper_postcode,
    shipper_telephone = new.shipper_telephone,
    dhl_fac_code = new.dhl_fac_code,
    mawb = new.mawb,
    processed = new.processed,
    csv_generated = new.csv_generated,
    hold = new.hold,
    heavy_weight = new.heavy_weight,
    tnt_error = new.tnt_error,
    processed_date = new.processed_date,
    archive_scanned = new.archive_scanned,
    dhl_email_weight = new.dhl_email_weight,
    sin_manifest_generated = new.sin_manifest_generated,
    date_scanned = new.date_scanned,
    fedex_residential_charge = new.fedex_residential_charge,
    pod_signature = new.pod_signature,
    pod_date = new.pod_date,
    pod_time = new.pod_time,
    pod_status = new.pod_status,
    driver_id = new.driver_id,
    driver_name = new.driver_name,
    dhl_vol_weight = new.dhl_vol_weight

I want so that the trigger can just execute the update statement which is coming in which can have 1 column or more than 1 column like shown above.

预期:应运行更新查询的列数不同 实际:对于上面定义的静态字段,效果很好。

0 个答案:

没有答案