English 中文(简体)
Informix: Fifo valuation with SQL/Stored procedures
原标题:

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.

最佳回答

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?

问题回答

暂无回答




相关问题
LINQ to SQL optional Column

I need a functionality to have optional columns in a LINQ to SQL definition. So that LINQ to SQL normally ignores this column within selects and updates etc. But if a select contains a value for this ...

Optional where clause / parameter in a SQL 2008 stored proc?

I m writing some code that updates a table. Depending on what the user wants to do, it either updates a large set of records, or a smaller one. The delineating factor is a group ID. The user can ...

How to control access to a Stored Procedure in SQL Server?

I want to be able to have a Stored Procedure that can only be used from a particular page, without having to create a permissions / role for a user, when it is just a single stored procedure I want ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签