On Thu, Jun 4, 2009 at 4:40 PM, Radcon Entec <radconentec@yahoo.com> wrote:
> Merlin,
>
> Thank you for your reply. Unfortunately, I was not able to get it to work.
> The SQL statements you gave me generated syntax errors.
>
> I tried to follow your thoughts, though. I created the following type:
>
> CREATE TYPE chargeneedstype AS
> (needsfs int2,
> needsdrygas int2,
> needsbigbase int2);
> ALTER TYPE chargeneedstype OWNER TO postgres;
> Then, I created a test function:
>
> CREATE OR REPLACE FUNCTION chargeneeds2(chargenumber int4)
> RETURNS chargeneedstype AS
> $BODY$
> declare
> CoilID varchar;
> InventoryRec record;
> result chargeneedstype;
> begin
> result.needsFS := 1;
> result.needsBigBase := 2;
> result.needsDryGas := 3;
> return result;
> end;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE;
I made a typo. try:
select charge, (cn).* from (select chargeneeds(charge) as cn from charge) q;
I think usually it's better to use 'out' parameters to functions than
to create a composite type.
merlin