put target rebuild in a proc

This commit is contained in:
Paul Trowbridge 2025-09-08 08:50:28 -04:00
parent 581224dad8
commit 5ec3f1d9c1

View File

@ -1,29 +1,28 @@
BEGIN; CREATE OR REPLACE PROCEDURE pricequote.refresh_target_prices_base()
DELETE FROM pricequote.target_prices_base; LANGUAGE plpgsql
AS $$
BEGIN
DELETE FROM pricequote.target_prices_base;
WITH WITH expand AS (
expand AS ( SELECT
SELECT c.compset,
c.compset, c.stlc,
c.stlc, c.floor,
c.floor, b.ds,
b.ds, b.chan,
b.chan, b.tier,
b.tier, b.vol,
b.vol, b.val,
b.val, b.price,
b.price, b.math AS math
b.math math FROM pricequote.core_target c
FROM LEFT JOIN LATERAL pricequote.build_pricing_path_base(
pricequote.core_target c c.options || jsonb_build_object('entity','Anchor','attr',c.stlc,'val',c.floor,'func','Price')
LEFT JOIN LATERAL pricequote.build_pricing_path_base (options||jsonb_build_object('entity','Anchor','attr',c.stlc,'val',c.floor,'func','Price')) b ON b.lastflag ) AS b
) ON b.lastflag
-- select count(*) from expand )
INSERT INTO INSERT INTO pricequote.target_prices_base
pricequote.target_prices_base SELECT * FROM expand;
SELECT END;
* $$;
FROM
expand;
COMMIT;