pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Gaab <A.Gaab@scanlab.de>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: aggregation of setof
Date: Mon, 31 Jan 2011 09:52:23 +0100
Message-ID: <48DA836F3865C54B8FBF424A3B775AF6671A6838F8@Exchange-Server> (raw)
In-Reply-To: <AANLkTiktEu9-CyN5ghEqPmPoKVaNYqfXtwBtK=QDK997@mail.gmail.com>
References: <48DA836F3865C54B8FBF424A3B775AF60132434B4A@Exchange-Server>
	<AANLkTiktEu9-CyN5ghEqPmPoKVaNYqfXtwBtK=QDK997@mail.gmail.com>

Functions apparently cannot take setof arguments.

Postgres 8.4:

CREATE OR REPLACE FUNCTION testtable(IN setof anyarray)
  RETURNS anyarray AS
$BODY$
SELECT $1 LIMIT 1;
$BODY$
  LANGUAGE 'sql' STABLE;

-->
ERROR:  functions cannot accept set arguments



Von: Viktor Bojović [mailto:viktor.bojovic@gmail.com]
Gesendet: Samstag, 29. Januar 2011 09:28
An: Andreas Gaab
Betreff: Re: [SQL] aggregation of setof

i have never used that type but maybe you can try this;
-create function which returns text[], and takse setof text as argument (if possible)
-reach every text[] in set of text[] using array index
-return values using "return next" for each text in text[] which is in set of text[]

On Fri, Jan 28, 2011 at 12:42 PM, Andreas Gaab <A.Gaab@scanlab.de<mailto:A.Gaab@scanlab.de>> wrote:
Hi all,

I would like to write a query, which aggregates the results of regexp_matches(). The problem is that regexp_matches returnes setof text[] as documented even if I discard the global flag (http://www.postgresql.org/docs/8.4/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP ). Thus resulting in an error when I try to aggregate the result:

“
SELECT array_accum(
regexp_matches('foobarbequebazilbarfbonk', '(b[^b]+)(b[^b]+)')
)
-------------------------------
ERROR:  set-valued function called in context that cannot accept a set
********** Fehler **********
ERROR: set-valued function called in context that cannot accept a set
SQL Status:0A000
“

Can I convert a ‚setof text[]‘ to a ‚text[]‘?

Alternatively I could use a sub-select, but I am curious if there are other solutions around.

Regards,
Andreas

___________________________________________________________________________

SCANLAB AG
Dr. Andreas Simon Gaab
Entwicklung • R & D

Siemensstr. 2a • 82178 Puchheim • Germany
Tel. +49 (89) 800 746-513 • Fax +49 (89) 800 746-199
mailto:a.gaab@scanlab.de • www.scanlab.de<http://www.scanlab.de;

Amtsgericht München: HRB 124707 • USt-IdNr.: DE 129 456 351
Vorstand: Georg Hofner (Sprecher), Christian Huttenloher, Norbert Petschik
Aufsichtsrat (Vorsitz): Dr. Hans J. Langer
___________________________________________________________________________




--
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me


view thread (6+ messages)  latest in thread

Message-ID: <48DA836F3865C54B8FBF424A3B775AF6671A6838F8@Exchange-Server>
Permalink:  ../48DA836F3865C54B8FBF424A3B775AF6671A6838F8@Exchange-Server/
Also on:    postgresql.org/message-id/48DA836F3865C54B8FBF424A3B775AF6671A6838F8@Exchange-Server

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: A.Gaab@scanlab.de
  Subject: Re: aggregation of setof
  In-Reply-To: <48DA836F3865C54B8FBF424A3B775AF6671A6838F8@Exchange-Server>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox