Re: RETURNS SETOF primitive returns results in parentheses

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: RETURNS SETOF primitive returns results in parentheses
Date: 2005-10-26 14:46:36
Message-ID: 20051026074400.Y22162@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Volkan YAZICI 2005-10-26 15:16:13 Combining two SELECTs by same filters
Previous Message Scott Marlowe 2005-10-26 14:44:51 Re: why vacuum