pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Mario Splivalo <mario.splivalo@mobart.hr>
Cc: pgsql-sql@postgresql.org
Subject: Re: RETURNS SETOF primitive returns results in parentheses
Date: Wed, 26 Oct 2005 07:46:36 -0700 (PDT)
Message-ID: <20051026074400.Y22162@megazone.bigpanda.com> (raw)
In-Reply-To: <1130330322.7400.45.camel@ekim>
References: <1130330322.7400.45.camel@ekim>

On Wed, 26 Oct 2005, Mario Splivalo wrote:

> Consider this function:
>
> CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4,
> "varchar")
>   RETURNS SETOF "varchar" AS
> $BODY$
> DECLARE
> 	aRecordID ALIAS FOR $1;
> 	aSubFieldId ALIAS FOR $2;
>
> 	returnValue record;
> 	subFieldNumber char(3);
> 	subFieldLetter char(1);
>
> BEGIN
> 	subFieldNumber = substr(aSubFieldId, 1, 3);
> 	subFieldLetter = substr(aSubFieldId, 4);
>
> 	FOR returnValue IN SELECT "subfieldValue"::varchar
> 				FROM "records_sub"
> 				WHERE "fieldTag" = subFieldNumber AND "subfieldTag" = subFieldLetter
> AND "recordId" = aRecordId
> 	LOOP
> 		RETURN NEXT returnValue;

I think the root cause is that you're not returning a varchar here, but
instead a record containing a varchar (if I return next
returnValue."subfieldValue" I don't seem to get parens).  I'm not sure why
it's allowing you to do so, though, it seems like that shouldn't match the
return type.



view thread (8+ messages)  latest in thread

Message-ID: <20051026074400.Y22162@megazone.bigpanda.com>
Permalink:  ../20051026074400.Y22162@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20051026074400.Y22162@megazone.bigpanda.com

 · 

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: sszabo@megazone.bigpanda.com, mario.splivalo@mobart.hr
  Subject: Re: RETURNS SETOF primitive returns results in parentheses
  In-Reply-To: <20051026074400.Y22162@megazone.bigpanda.com>

* 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