From da9e9b08f18eb5fe42b315778170080108dd5ca9 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 31 May 2018 10:24:15 -0400 Subject: [PATCH] sort collateral on id that needs to be in view, alter view creation to include ids --- deploy/setup.sql | 2 +- interface/source_maint/srce_build_view.sql | 2 +- reports/colateral_balalance.sql | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deploy/setup.sql b/deploy/setup.sql index 41f8291..9023077 100644 --- a/deploy/setup.sql +++ b/deploy/setup.sql @@ -319,7 +319,7 @@ BEGIN _path:= ARRAY['schemas',_schema]::text[]; --_srce:= 'dcard'; SELECT - 'CREATE VIEW tpsv.'||_srce||'_'||_path[2]||' AS SELECT '||string_agg('(allj#>>'''||r.PATH::text||''')::'||r.type||' AS "'||r.column_name||'"',', ')||' FROM tps.trans WHERE srce = '''||_srce||'''' + 'DROP VIEW IF EXISTS tpsv.'||_srce||'_'||_path[2]||'; CREATE VIEW tpsv.'||_srce||'_'||_path[2]||' AS SELECT id, logid, '||string_agg('(allj#>>'''||r.PATH::text||''')::'||r.type||' AS "'||r.column_name||'"',', ')||' FROM tps.trans WHERE srce = '''||_srce||''';' INTO _sql FROM diff --git a/interface/source_maint/srce_build_view.sql b/interface/source_maint/srce_build_view.sql index 35addf6..5b6710e 100644 --- a/interface/source_maint/srce_build_view.sql +++ b/interface/source_maint/srce_build_view.sql @@ -12,7 +12,7 @@ BEGIN _path:= ARRAY['schemas',_schema]::text[]; --_srce:= 'dcard'; SELECT - 'CREATE VIEW tpsv.'||_srce||'_'||_path[2]||' AS SELECT '||string_agg('(allj#>>'''||r.PATH::text||''')::'||r.type||' AS "'||r.column_name||'"',', ')||' FROM tps.trans WHERE srce = '''||_srce||'''' + 'DROP VIEW IF EXISTS tpsv.'||_srce||'_'||_path[2]||'; CREATE VIEW tpsv.'||_srce||'_'||_path[2]||' AS SELECT id, logid, '||string_agg('(allj#>>'''||r.PATH::text||''')::'||r.type||' AS "'||r.column_name||'"',', ')||' FROM tps.trans WHERE srce = '''||_srce||''';' INTO _sql FROM diff --git a/reports/colateral_balalance.sql b/reports/colateral_balalance.sql index 5641c54..cb0e80a 100644 --- a/reports/colateral_balalance.sql +++ b/reports/colateral_balalance.sql @@ -10,10 +10,10 @@ SELECT FROM tpsv.pncl_default r WHERE - --AND rec @> '{"Schedule#":"01AR"}' - --AND rec @> '{"Schedule#":"02IN Raw Material"}' - "Schedule#" = '03IN Finished Goods' - + "Schedule#" = '01AR' + --"Schedule#" = '02IN Raw Material' + --"Schedule#" = '03IN Finished Goods' ORDER BY "Schedule#" asc - ,r."PostDate" asc \ No newline at end of file + ,r."PostDate" asc + ,id \ No newline at end of file