sales_walk/sql/write_note.sql

15 lines
528 B
MySQL
Raw Normal View History

2023-09-01 08:29:11 -04:00
MERGE INTO
2023-10-18 15:00:33 -04:00
rlarp.walk_r1 w
2023-09-01 08:29:11 -04:00
USING
2023-10-24 16:22:00 -04:00
( SELECT $1 bill_cust, $2 ship_cust, $3 bucket, $4 attainment, $5 notes, $6 fcnotes) as i ON
2023-09-01 08:29:11 -04:00
i.ship_cust = w.ship_cust
2023-10-18 15:00:33 -04:00
AND i.bill_cust = w.bill_cust
2023-09-01 08:29:11 -04:00
WHEN MATCHED THEN UPDATE SET
bucket = i.bucket
2023-10-18 15:00:33 -04:00
,attainment = i.attainment::numeric
2023-09-01 08:29:11 -04:00
,notes = i.notes
2023-10-24 16:22:00 -04:00
,fcnotes = i.fcnotes
2023-09-01 08:29:11 -04:00
WHEN NOT MATCHED THEN
2023-10-24 16:22:00 -04:00
INSERT (bill_cust, ship_cust, bucket, attainment, notes, fcnotes)
VALUES (bill_cust,i.ship_cust, i.bucket, i.attainment::numeric, i.notes , i.fcnotes)