lanetix=# \d foo
Table "scripting.foo"
Column | Type | Modifiers
--------+-----------------------+-----------
id | integer | not null
a | character varying(40) | not null
b | character varying(40) | not null
c | character varying(40) | not null
lanetix=# BEGIN; DELETE FROM foo; INSERT INTO foo SELECT * from json_populate_recordset(null::foo, '[ {"id": 0, "a": "harold", "b": "wilson", "c": "j"}, {"id": 1, "a": "brian", "b": "wilson", "c": "q"}, {"id": 2, "a": "jack", "b": "kemp", "c": "q"} ]'); COMMIT;
BEGIN
DELETE 0
INSERT 0 3
COMMIT
lanetix=# select * from foo;
id | a | b | c
----+--------+--------+---
0 | harold | wilson | j
1 | brian | wilson | q
2 | jack | kemp | q
(3 rows)
Created
February 29, 2016 22:23
json_populate_recordset example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment