From 55dcb65a171494727f4b92ade9f5d0cffbb59174 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 4 Nov 2020 22:58:13 -0500 Subject: [PATCH] new column list to increment date periods --- sql/col_interval.sql | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sql/col_interval.sql diff --git a/sql/col_interval.sql b/sql/col_interval.sql new file mode 100644 index 0000000..176004d --- /dev/null +++ b/sql/col_interval.sql @@ -0,0 +1,27 @@ +DO +$$ +DECLARE + clist text; + +BEGIN +-------------------------------build a column list---------------------------------------- +SELECT + string_agg( + format('%I',cname) || CASE WHEN func IN ('odate','sdate') THEN ' + interval ''1 year''' ELSE '' END,E'\n,' ORDER BY opos ASC) +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;