Re: Help trying to write my first plpgsql function...
| От | hubert depesz lubaczewski |
|---|---|
| Тема | Re: Help trying to write my first plpgsql function... |
| Дата | |
| Msg-id | 9e4684ce05091910516c189b89@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: Help trying to write my first plpgsql function... (Bjørn T Johansen <btj@havleik.no>) |
| Список | pgsql-general |
On 9/19/05, Bjørn T Johansen <btj@havleik.no> wrote:
why do you use subselect here?
just do:
select 1 as colid, ordenew.id..... into tmprec from ordrenew left ....;
dont forget to add "return;" before END;
depesz
CREATE OR REPLACE FUNCTION trykkStatus (pressID INTEGER)
RETURNS SetOf trykkstatus_type AS '
DECLARE
orderID ordrenew.id%TYPE;
tmprec trykkstatus_type%ROWTYPE;
BEGIN
select id into orderID from ordrenew where now() between trykkstart and produsert and
presseid = pressID limit 1;
if not found then
return;
end if;
select into tmprec (select 1 as colid, ordrenew.id, trykkstart, produsert,
presseid, product.name from ordrenew left outer join product on ordrenew.productid =
product.id where produsert < (select trykkstart from ordrenew where id=orderID) and
presseid = pressID order by produsert desc limit 1);
why do you use subselect here?
just do:
select 1 as colid, ordenew.id..... into tmprec from ordrenew left ....;
return next tmprec;
END;
dont forget to add "return;" before END;
depesz
В списке pgsql-general по дате отправления: