[GENERAL] hstore syntax

2013-12-08 Thread Kaare Rasmussen
Hi Trying to write a sql function to return hstore generated from a select. But I'm thinking there must be a better way. SELECT 'key = ' || s.part || '')::hstore is neither pretty nor secure. At least I need to escape any '' in s.part. I'll do so if there's no better way to write this (?)

Re: [GENERAL] hstore syntax

2013-12-08 Thread Magnus Hagander
On Sun, Dec 8, 2013 at 11:22 AM, Kaare Rasmussen ka...@jasonic.dk wrote: Hi Trying to write a sql function to return hstore generated from a select. But I'm thinking there must be a better way. SELECT 'key = ' || s.part || '')::hstore is neither pretty nor secure. At least I need to

Re: [GENERAL] hstore syntax

2013-12-08 Thread Kaare Rasmussen
On 12/08/2013 11:45 AM, Magnus Hagander wrote: If it's just for a single value, you can just use SELECT hstore('key', s.part) It also takes array (either one big array, or one array of keys and one array of values). Super! I knew I was missing the obvious. -- Sent via pgsql-general

[GENERAL] Set returning aggregate?

2013-12-08 Thread Bborie Park
I'm wondering if an aggregate function can return a set of records? Say I have a table with a column of type raster (PostGIS). I want to get the number of times the pixel values 1, 3 and 4 occur in that raster column. I am hoping to build an aggregrate function that returns the following...

Re: [GENERAL] Set returning aggregate?

2013-12-08 Thread Pavel Stehule
Hello 2013/12/8 Bborie Park dustym...@gmail.com I'm wondering if an aggregate function can return a set of records? No, final function cannot returns set. It is disallowed. Theoretically, it should be possible - it is explicitly prohibited. But if it will be allowed, you can get same