2020-11-04 22:58:13 -05:00
|
|
|
DO
|
|
|
|
$$
|
|
|
|
DECLARE
|
|
|
|
clist text;
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
-------------------------------build a column list----------------------------------------
|
|
|
|
SELECT
|
|
|
|
string_agg(
|
2020-11-05 22:32:27 -05:00
|
|
|
format('%I',cname) || CASE WHEN func IN ('odate','sdate') AND dtype = 'date' THEN ' + interval ''1 year''' ELSE '' END,E'\n,' ORDER BY opos ASC)
|
2020-11-04 22:58:13 -05:00
|
|
|
INTO
|
|
|
|
clist
|
|
|
|
FROM
|
|
|
|
fc.target_meta
|
|
|
|
WHERE
|
|
|
|
func NOT IN ('version');
|
|
|
|
|
|
|
|
RAISE NOTICE 'build list: %',clist;
|
|
|
|
|
|
|
|
CREATE TEMP TABLE sql(t text);
|
|
|
|
|
|
|
|
INSERT INTO sql SELECT clist;
|
|
|
|
|
|
|
|
END
|
|
|
|
$$;
|
|
|
|
|
|
|
|
select * from sql;
|