Skip to content

Instantly share code, notes, and snippets.

@adunstan
adunstan / skeleton_query.sql
Last active January 23, 2019 20:50
generate a select query for a given table, with optional alias and compaction
create or replace function make_select_query (tablename text, tablealias text default null, compact boolean default false)
returns text
language plpgsql as
$$
declare
rec record;
crec record;
firstrow boolean := true;
result text := '';
@adunstan
adunstan / gist:803432
Created January 30, 2011 23:47
query_to_json.sql
create or replace function xml2json (xml) returns text
language plperlu as
$func$
use XML::XML2JSON;
use strict;
my $xml = shift;
my $XML2JSON = XML::XML2JSON->new(pretty => 0); # 1 for readable json