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