sort collateral on id that needs to be in view, alter view creation to include ids

This commit is contained in:
Paul Trowbridge 2018-05-31 10:24:15 -04:00
parent 86f72b4d97
commit da9e9b08f1
3 changed files with 7 additions and 7 deletions

View File

@ -319,7 +319,7 @@ BEGIN
_path:= ARRAY['schemas',_schema]::text[]; _path:= ARRAY['schemas',_schema]::text[];
--_srce:= 'dcard'; --_srce:= 'dcard';
SELECT 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 INTO
_sql _sql
FROM FROM

View File

@ -12,7 +12,7 @@ BEGIN
_path:= ARRAY['schemas',_schema]::text[]; _path:= ARRAY['schemas',_schema]::text[];
--_srce:= 'dcard'; --_srce:= 'dcard';
SELECT 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 INTO
_sql _sql
FROM FROM

View File

@ -10,10 +10,10 @@ SELECT
FROM FROM
tpsv.pncl_default r tpsv.pncl_default r
WHERE WHERE
--AND rec @> '{"Schedule#":"01AR"}' "Schedule#" = '01AR'
--AND rec @> '{"Schedule#":"02IN Raw Material"}' --"Schedule#" = '02IN Raw Material'
"Schedule#" = '03IN Finished Goods' --"Schedule#" = '03IN Finished Goods'
ORDER BY ORDER BY
"Schedule#" asc "Schedule#" asc
,r."PostDate" asc ,r."PostDate" asc
,id