unwrap the newly created json arrangement and dynamically create a temp table
This commit is contained in:
parent
750d91b8e9
commit
39d734bb41
32
srce.pgsql
32
srce.pgsql
@ -1,3 +1,4 @@
|
||||
/*
|
||||
SELECT
|
||||
jsonb_pretty(
|
||||
$$
|
||||
@ -40,3 +41,34 @@ $$
|
||||
}
|
||||
$$::jsonb
|
||||
)
|
||||
*/
|
||||
|
||||
DO $$
|
||||
|
||||
declare _t text;
|
||||
|
||||
begin
|
||||
|
||||
SELECT
|
||||
string_agg(quote_ident(prs.key)||' '||prs.type,',')
|
||||
INTO
|
||||
_t
|
||||
FROM
|
||||
TPS.srce
|
||||
--unwrap the schema definition array
|
||||
LEFT JOIN LATERAL jsonb_populate_recordset(null::tps.srce_defn_schema, defn->'schema') prs ON TRUE
|
||||
GROUP BY
|
||||
srce;
|
||||
|
||||
raise notice '%', _t;
|
||||
_t := format('CREATE TEMP TABLE csv_i (%s)', _t);
|
||||
raise notice '%', _t;
|
||||
|
||||
DROP TABLE IF EXISTS csv_i;
|
||||
|
||||
EXECUTE _t;
|
||||
|
||||
end
|
||||
$$;
|
||||
|
||||
SELECT * FROM csv_i;
|
Loading…
Reference in New Issue
Block a user