Created
February 18, 2015 03:52
-
-
Save quintessence/f3f6afc8f23a57345e8a to your computer and use it in GitHub Desktop.
transformServers.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- transforms JSONB row data to columns | |
CREATE OR REPLACE FUNCTION transformServers(data jsonb) | |
RETURNS SETOF RECORD as $$ | |
DECLARE | |
serversSet RECORD; | |
BEGIN | |
return query | |
SELECT jsonb_to_recordset(data->'data') INTO | |
serversSet ( | |
id bigint, | |
hostname text, | |
nickname text, | |
os text, | |
created text, | |
running text, | |
capacity_cpu_freq text, | |
description text, | |
location_ip text, | |
capacity_cpu_num text, | |
capacity_mem text, | |
current_version text, | |
os_detail text, | |
architecture text, | |
guid text, | |
capacity_disk jsonb, | |
network_interfaces jsonb, | |
url text | |
); | |
END; | |
$$ language plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment