Re: Newbie question re SQL

Поиск
Список
Период
Сортировка
От missive@frontiernet.net (Lee Harr)
Тема Re: Newbie question re SQL
Дата
Msg-id slrna850fo.4a.missive@whave.frontiernet.net
обсуждение исходный текст
Ответ на Re: Newbie question re SQL  (missive@frontiernet.net (Lee Harr))
Список pgsql-general
>>> Quan     Price       Cost
>>>====     =====       ====
>>>  300     125       37,500
>>>  500     135       67,500
>>> (100)     110      (13,125)  <-- how do you get this number?
>
> When I sell a security, to calculate the cost of the remaining
> identical securities, I must subtract from my total cost before the
> sale the number of units sold * their cost per unit (not their fair
> market value at the time of the sale).
>

I was reading recently that it can be helpful to access the
database _only_ through functions. Basically, create an API
for accessing your data. So you might create functions:

buy(id, quan, price)
sell(id, quan, price)

which would deal with your accounting situation.

Maybe you could keep a table with the to-date cost which
gets updated each time you buy() or sell()

You might also look at sourceforge.net as I remember reading
about an accounting system written for sql databases.
(Someone may already have scratched this itch :)





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

Предыдущее
От: Patrick Welche
Дата:
Сообщение: Re: oids vs. serial question
Следующее
От: knut.suebert@web.de
Дата:
Сообщение: Re: oids vs. serial question