RETURNS SETOF primitive returns results in parentheses - Mailing list pgsql-sql

Consider this function:

CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4,
"varchar") RETURNS SETOF "varchar" AS
$BODY$
DECLAREaRecordID ALIAS FOR $1;aSubFieldId ALIAS FOR $2;
returnValue record;subFieldNumber char(3);subFieldLetter char(1);

BEGINsubFieldNumber = substr(aSubFieldId, 1, 3);subFieldLetter = substr(aSubFieldId, 4);
FOR returnValue IN SELECT "subfieldValue"::varchar            FROM "records_sub"             WHERE "fieldTag" =
subFieldNumberAND "subfieldTag" = subFieldLetter
 
AND "recordId" = aRecordIdLOOP    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)

I have return values in parentheses. However, if I create a new type:

CREATE TYPE subfield_data_type AS (subfield_data varchar);

And then drop the function and recreate it like this:

CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4,
"varchar") RETURNS SETOF subfield_data_type AS
$BODY$
...

And then when I run the function, the results are ok:

biblio3=# select * from php_get_subfield_data_repeating(1,'606a');subfield_data
---------------Anđeliofsajd
(2 rows)


Am I doing something wrong here? Why do I need to create type with only
one member of type varchar to have results without the parentheses?
Mike

P.S. The subFieldValue field in the records_sub table is of type
varchar(4096).


-- 
Mario Splivalo
Mob-Art
mario.splivalo@mobart.hr

"I can do it quick, I can do it cheap, I can do it well. Pick any two."





pgsql-sql by date:

Previous
From: Sean Davis
Date:
Subject: Re: SETOF RECORD RETURN VALUE
Next
From: Sean Davis
Date:
Subject: Re: RETURNS SETOF primitive returns results in parentheses