Re: Another plpgsql question..

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Another plpgsql question..
Дата
Msg-id 6224.980265414@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Another plpgsql question..  ("Mitch Vincent" <mitch@venux.net>)
Список pgsql-general
"Mitch Vincent" <mitch@venux.net> writes:
> CREATE FUNCTION invoice_payment() RETURNS OPAQUE AS '
> BEGIN

>    UPDATE invoice_master SET total = total - NEW.amount,updated = now(),
> is_paid=(CASE WHEN (total - NEW.amount) = 0.00 THEN ''t'' ELSE ''f'' END)
> WHERE invoice_id = NEW.invoice_id;

>    RETURN NEW;

> END;
> ' LANGUAGE 'plpgsql';

> Ok, thanks for the heads up on now().. That works but I add the last part of
> the query in there and everything but the last part works.. Can I not do
> CASE WHEN statements in functions like that? That query works when I run it
> straight from psql but so did the other, so I'm wondering if the same kind
> of problem is happening here too..

It looks fine to me.  Please define "everything but the last part works"
more precisely.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: "Mitch Vincent"
Дата:
Сообщение: plpgsql - cont'd
Следующее
От: "Mitch Vincent"
Дата:
Сообщение: Re: Another plpgsql question..