Sha256: 4ab2c012ce5ab77ef4c805f857f2f384e49712c16a37a9ba751856dcfb52ffa1
Contents?: true
Size: 672 Bytes
Versions: 161
Compression:
Stored size: 672 Bytes
Contents
CREATE OR REPLACE FUNCTION audit_view_as_json(view_name text) /* Converts the specified view into its json representation suitable for feeding for example into jQuery datatables plugin, or creating a historical snapshot. Example usage: select audit_view_as_json('reporting_bone_audit') TC 1.11.2017 */ RETURNS json LANGUAGE 'plpgsql' as $$ DECLARE result json; BEGIN EXECUTE format(' select row_to_json(t) from ( select current_timestamp as runat, (select array_to_json(array_agg(row_to_json(d)) ) from (select * from %s) d) as data) t; ', quote_ident(view_name)) into result; return result; END $$;
Version data entries
161 entries across 161 versions & 1 rubygems