return modified data from a function

Поиск
Список
Период
Сортировка
От Raimon Fernandez
Тема return modified data from a function
Дата
Msg-id C8AFAEE5-B5A8-4EA1-814B-442F5F0F0A8F@montx.com
обсуждение исходный текст
Ответы Re: return modified data from a function  (Rodrigo De León <rdeleonp@gmail.com>)
Список pgsql-novice
Hi,

We have a table for an account system:

table:
compte


fields:
detail => varchar
deure => float
haver => float


some data:

detail: Entrada
deure: 0
haver: 5000

detail: Sortida
deure: 100
haver: 0

detail: Comptes
deure: 150
haver: 0

detail: Varis
deure: 35
haver: 0


We want to retrieve all this records, with an extra column with the
difference from deure-haver, like this:


Entrada 0 5000 5000
Sortida 100 0 4900
Comptes 150 0 4750
Varis 35 0 4715

We tried using functions, with a cursor, and add an extra column or
tried to create a view, but without success ...

We have a workaround using our frontend, and there we calculate the
difference, but we want to do it from PostgreSQL.

It's easy to do it ?


thanks in advance,

regards,


raimon fernandez
barcelona



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

Предыдущее
От: Andrew Jarcho
Дата:
Сообщение: Re: call stored function from ecpg w/cursor
Следующее
От: "Nuno Monteiro"
Дата:
Сообщение: Migration Issues