Search Postgresql Archives

Re: Using a multi-valued function in a view

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 4, 2009 at 4:40 PM, Radcon Entec <radconentec@xxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux