Re: Using a multi-valued function in a view
От | Merlin Moncure |
---|---|
Тема | Re: Using a multi-valued function in a view |
Дата | |
Msg-id | b42b73150906041358x4479975fo6977c5216faa42a4@mail.gmail.com обсуждение исходный текст |
Ответ на | Using a multi-valued function in a view (Radcon Entec <radconentec@yahoo.com>) |
Ответы |
Re: Using a multi-valued function in a view
|
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: