Re: PGSQL function question

Поиск
Список
Период
Сортировка
От Peter Gibbs
Тема Re: PGSQL function question
Дата
Msg-id 017801c2de6a$5f1c8740$0b01010a@emkel.co.za
обсуждение исходный текст
Ответ на PGSQL function question  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
Список pgsql-general
Jean-Christian Imbeault wrote:
> I have created a pgpsql function but it does not return the expected
> value. It's a simple sql query, and if I do the same query by hand I get
> the expected result so I can't see what is wrong.

> create or replace function member_points_to_be_refunded(integer) returns
> integer as '
>    declare points_used integer := 0;
>    begin
>      SELECT into points_used sum(points_used)

You are using the same name for the local variable inside the function
as the column name, therefore you are actually summing the local variable.
Use a different name, or qualify the column name i.e.
sum(invoices.points_used)
--
Peter Gibbs
EmKel Systems


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

Предыдущее
От: "Matthew Nuzum"
Дата:
Сообщение: selective copy
Следующее
От: Antti Haapala
Дата:
Сообщение: Re: SETOF (was: Function example returning more then 1