remove single quotes from open order status since they shoudl be supplied by the request, and couple more quoted identifiers

This commit is contained in:
Paul Trowbridge 2022-04-03 01:18:14 -04:00
parent a859ffa91a
commit c97e92f3bc

View File

@ -107,7 +107,7 @@ WHERE
--base period orders booked.... --base period orders booked....
$$||format('%I',_order_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date $$||format('%I',_order_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date
--...or any open orders currently booked before cutoff.... --...or any open orders currently booked before cutoff....
OR ($$||format('%I',_order_status)||$$ IN ('app_openstatus_code') and $$||format('%I',_order_date)||$$ <= 'app_openorder_cutoff'::date) OR ($$||format('%I',_order_status)||$$ IN (app_openstatus_code) and $$||format('%I',_order_date)||$$ <= 'app_openorder_cutoff'::date)
--...or anything that shipped in that period --...or anything that shipped in that period
OR ($$||format('%I',_ship_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date) OR ($$||format('%I',_ship_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date)
) )
@ -130,7 +130,7 @@ $$
FROM FROM
fc.live o$$||E'\n'||_perd_joins||$$ fc.live o$$||E'\n'||_perd_joins||$$
WHERE WHERE
$$||_order_date||$$ BETWEEN 'app_plug_fromdate'::date AND 'app_plug_todate'::date $$||format('%I',_order_date)||$$ BETWEEN 'app_plug_fromdate'::date AND 'app_plug_todate'::date
--be sure to pre-exclude unwanted items, like canceled orders, non-gross sales, and short-ships --be sure to pre-exclude unwanted items, like canceled orders, non-gross sales, and short-ships
$$ $$
INTO INTO
@ -158,8 +158,8 @@ SELECT
FROM FROM
incr i incr i
WHERE WHERE
i.$$||_order_date||$$ >= 'app_first_forecast_date'::date$$||$$ i.$$||format('%I',_order_date)||$$ >= 'app_first_forecast_date'::date$$||$$
OR i.$$||_ship_date||$$ >= 'app_first_forecast_date'::date$$||$$ OR i.$$||format('%I',_ship_date)||$$ >= 'app_first_forecast_date'::date$$||$$
RETURNING * RETURNING *
) )
SELECT COUNT(*) num_rows FROM ins$$ SELECT COUNT(*) num_rows FROM ins$$