pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sean Davis <sdavis2@mail.nih.gov>
To: mario.splivalo@mobart.hr
To: pgsql-sql@postgresql.org
Subject: Re: RETURNS SETOF primitive returns results in parentheses
Date: Wed, 26 Oct 2005 08:54:51 -0400
Message-ID: <BF84F4DB.11C9D%sdavis2@mail.nih.gov> (raw)
In-Reply-To: <1130330322.7400.45.camel@ekim>

On 10/26/05 8:38 AM, "Mario Splivalo" <mario.splivalo@mobart.hr> 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;
> END LOOP;
> 
> RETURN;
> END
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE;
> 
> 
> 
> Now, when I do this:
> 
> biblio3=# select * from php_get_subfield_data_repeating(1,'606a');
> php_get_subfield_data_repeating1
> ----------------------------------
> (An©¢eli)
> (ofsajd)
> (2 rows)

Does:

select * from php_get_subfield_data_repeating(1,'606a') as s(a)

do what you want (single column)?




view thread (8+ messages)  latest in thread

Message-ID: <BF84F4DB.11C9D%sdavis2@mail.nih.gov>
Permalink:  ../BF84F4DB.11C9D%25sdavis2@mail.nih.gov/
Also on:    postgresql.org/message-id/BF84F4DB.11C9D%sdavis2@mail.nih.gov

 · 

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: sdavis2@mail.nih.gov, mario.splivalo@mobart.hr
  Subject: Re: RETURNS SETOF primitive returns results in parentheses
  In-Reply-To: <BF84F4DB.11C9D%sdavis2@mail.nih.gov>

* 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