views:

93

answers:

1

I am using IDS 10 and I have a simple transaction table with the inventory changes with product ID, transaction time, volume, quantity and price.
Is it possible to determine the FIFO valuation solely with SQL/Stored procedures or do I need to use something like Perl with DBI for the cursor handling?
Fifo valuation requires cursor-handling from my pov as I need to first build a temp table with the total volume and process then the sorted transaction to calculate the average on the relevant transactions.

+1  A: 

It should certainly be possible to do it in a stored procedure. You can create temporary tables and use cursors via the FOREACH statement. I doubt if it is doable in straight SQL.

FIFO evaluation - as in, I bought 27 lots of a particular share are various times and prices; now I sold a bunch of those shares and need to work out the cost basis using FIFO?

Jonathan Leffler
Thanks for the answer - your FIFO summary hits what I need.
weismat