From 31172e7e35798ea4883eaa14acafea0f08d986d8 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 1 Oct 2025 09:55:56 -0400 Subject: [PATCH] work on targeting a new db --- procs/single_price_call.ms.sql | 14 +++++++------- rebuild/rebuild_lastprice.ms.sql | 2 +- rebuild/rebuild_main.ms.sql | 8 ++++---- rebuild/rebuild_pricelist.ms.sql | 2 +- tables/cust.ms.sql | 0 tables/lastpricedetail.ms.sql | 4 ++-- tables/pricelist_ranged.ms.sql | 3 ++- tables/repc.ms.sql | 18 ++++++++++++++++++ 8 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 tables/cust.ms.sql create mode 100644 tables/repc.ms.sql diff --git a/procs/single_price_call.ms.sql b/procs/single_price_call.ms.sql index c9b56d5..2d07dcd 100644 --- a/procs/single_price_call.ms.sql +++ b/procs/single_price_call.ms.sql @@ -200,8 +200,8 @@ BEGIN calculated_pallets = FLOOR(q.vol / NULLIF(i.mpck, 0)), exact_pallets = CAST(ROUND(q.vol / NULLIF(i.mpck, 0), 5) AS NUMERIC(20,5)) FROM @queue q - LEFT JOIN rlarp.cust bc ON bc.code = q.bill - LEFT JOIN rlarp.cust sc ON sc.code = q.ship + LEFT JOIN fanalysis.rlarp.cust bc ON bc.code = q.bill + LEFT JOIN fanalysis.rlarp.cust sc ON sc.code = q.ship LEFT JOIN CMSInterfaceIn.[CMS.CUSLG].itemm i ON i.item = q.part; @@ -279,16 +279,16 @@ BEGIN ,curstd_last = CASE WHEN last_isdiff = '' THEN q.curstd_orig ELSE COALESCE(v1l.curstdus, v0l.curstdus) END ,futstd_last = CASE WHEN last_isdiff = '' THEN q.futstd_orig ELSE COALESCE(v1l.futstdus, v0l.futstdus) END FROM @queue q - LEFT JOIN rlarp.cost_v1ds v1 ON + LEFT JOIN fanalysis.rlarp.cost_v1ds v1 ON v1.stlc = q.stlc AND v1.v1ds = q.v1ds - LEFT JOIN rlarp.cost_v0ds v0 ON + LEFT JOIN fanalysis.rlarp.cost_v0ds v0 ON v0.stlc = q.stlc AND v0.v0ds = q.v0ds - LEFT JOIN rlarp.cost_v1ds v1l ON + LEFT JOIN fanalysis.rlarp.cost_v1ds v1l ON v1l.stlc = q.stlc AND v1l.v1ds = q.last_dataseg - LEFT JOIN rlarp.cost_v0ds v0l ON + LEFT JOIN fanalysis.rlarp.cost_v0ds v0l ON v0l.stlc = q.stlc AND v0l.v0ds = q.last_v0ds; @@ -479,7 +479,7 @@ BEGIN SELECT 'Current Std' AS label, 5 AS detailLevel, - COALESCE(q.listprice,0) AS value, + COALESCE(q.curstd,0) AS value, 'currency' AS type, '' AS note FOR JSON PATH diff --git a/rebuild/rebuild_lastprice.ms.sql b/rebuild/rebuild_lastprice.ms.sql index 28bce1f..dbbe8bd 100644 --- a/rebuild/rebuild_lastprice.ms.sql +++ b/rebuild/rebuild_lastprice.ms.sql @@ -29,7 +29,7 @@ WITH base AS ( o.[Order Number] AS ordnum, o.[Quote Number] AS quoten FROM - rlarp.osm_stack_pretty o + fanalysis.rlarp.osm_stack_pretty o INNER JOIN CMSInterfaceIn.[CMS.CUSLG].ITEMM i ON i.item = o.[Part Code] WHERE diff --git a/rebuild/rebuild_main.ms.sql b/rebuild/rebuild_main.ms.sql index 1aaf698..e4226f7 100644 --- a/rebuild/rebuild_main.ms.sql +++ b/rebuild/rebuild_main.ms.sql @@ -1,6 +1,6 @@ -EXEC pricing.rebuild_lastprice; +EXEC pricing.pricing.rebuild_lastprice; --2:45 -EXEC pricing.rebuild_pricelist; +EXEC pricing.pricing.rebuild_pricelist; --14 secconds -EXEC pricing.rebuild_targets; ---9:49 +EXEC pricing.pricing.rebuild_targets; +--12:49 \ No newline at end of file diff --git a/rebuild/rebuild_pricelist.ms.sql b/rebuild/rebuild_pricelist.ms.sql index c157aeb..a35ae47 100644 --- a/rebuild/rebuild_pricelist.ms.sql +++ b/rebuild/rebuild_pricelist.ms.sql @@ -16,7 +16,7 @@ CREATE TABLE pricing.pricelist_ranged ( price float NOT NULL ); -CREATE NONCLUSTERED INDEX pricelist_ranged_idx ON FAnalysis.PRICING.pricelist_ranged ( jcpart ASC , jcplcd ASC , vb_from ASC , vb_to ASC ) ; +CREATE NONCLUSTERED INDEX pricelist_ranged_idx ON PRICING.pricelist_ranged ( jcpart ASC , jcplcd ASC , vb_from ASC , vb_to ASC ) ; --XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -----------------------------------------------------------traverse unit of measure graph----------------------------------------------------------------------- diff --git a/tables/cust.ms.sql b/tables/cust.ms.sql new file mode 100644 index 0000000..e69de29 diff --git a/tables/lastpricedetail.ms.sql b/tables/lastpricedetail.ms.sql index e52c201..39cc9f7 100644 --- a/tables/lastpricedetail.ms.sql +++ b/tables/lastpricedetail.ms.sql @@ -1,7 +1,7 @@ -CREATE TABLE lastpricedetail ( +CREATE TABLE pricing.lastpricedetail ( customer varchar(255), partgroup varchar(10), part_stats nvarchar(MAX) ); - CREATE UNIQUE NONCLUSTERED INDEX lastprice_cust_partgroup ON FAnalysis.PRICING.lastpricedetail ( customer ASC , partgroup ASC ); + CREATE UNIQUE NONCLUSTERED INDEX lastprice_cust_partgroup ON pricing.lastpricedetail ( customer ASC , partgroup ASC ); diff --git a/tables/pricelist_ranged.ms.sql b/tables/pricelist_ranged.ms.sql index fe36c12..73c0e52 100644 --- a/tables/pricelist_ranged.ms.sql +++ b/tables/pricelist_ranged.ms.sql @@ -8,4 +8,5 @@ CREATE TABLE pricing.pricelist_ranged ( vb_to float , price float ); - CREATE NONCLUSTERED INDEX pricelist_ranged_idx ON FAnalysis.PRICING.pricelist_ranged ( jcpart ASC , jcplcd ASC , vb_from ASC , vb_to ASC ); + + CREATE NONCLUSTERED INDEX pricelist_ranged_idx ON pricing.pricelist_ranged ( jcpart ASC , jcplcd ASC , vb_from ASC , vb_to ASC ); diff --git a/tables/repc.ms.sql b/tables/repc.ms.sql new file mode 100644 index 0000000..bbdfc90 --- /dev/null +++ b/tables/repc.ms.sql @@ -0,0 +1,18 @@ +ALTER VIEW pricing.repc AS +WITH +code AS ( + SELECT + ltrim(rtrim(c.a9)) rcode + ,(ltrim(rtrim(c.a9)) + ' - ') + c.a30 repp + FROM + CMSInterfaceIN.lgdat.code c + WHERE c.a2 = 'MM' +) +SELECT + COALESCE(c.rcode,q.qr) rcode + ,COALESCE(c.repp,q.qr) repp + ,COALESCE(q.dir,'Other') director +FROM + code c + FULL OUTER JOIN rlarp.qrh q ON + q.qr = c.rcode