| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера