Subject RE: [firebird-support] Righ way of doing that ?
Author sasha
> Hi to all !
> I develop an application based on stock management,I use VB
> .Net 2005 with FB.I also need to keep a stock table based on
> I/O in month (a table) and stock from last month (another
> table). I'm looking for the right way to do it.I'm new with
> FB, the solved way for me is using some .Net datasets (this
> is based on load needed data from server in memory, manage
> and then send to database for updating. ),but I think it's
> not the right way,it is also very slow.I thing it may be
> another way based only on firebird/stored procedure.

I don't exactly understand what you mean by stock management,
is it stock as in what they trade on Wallstreet or is stock
as in you have some products, warehouses, and customers.
In either case the basic principle is the same. I'll try to
give you a couple of hints, but it's up to you to implement
and test it.

You don't need separate tables based on current/previous
month. You need 1 table that that will be updated with triggers
(never use client code for that, in your case .Net, because it will
always be slower and you'll have a mess of code to manage), do it
once on server with stored procedures and triggers and your .Net code
will be much cleaner and easier (since there will be NO code).

Another thing is that previous months should not be handled with
stock table, they should be selected on date column from your
in/out documents. Actually, the definition of stock from last month
is a sign of wrong desing. There is no such thing. For example,
if your stock quantity changes thru the month, what is the value
of stock quantity for that month? The question has no meaning as such,
you have to change the question to what is the value on specific day
(assuming your minimum time period is 1 day, of course, because when
you are dealing with dates (no matter what platform you use) you are
not dealing with points in time but intervals in time).

What you need to understand is that these things are not Firebird
specific, if you choose another database those same problems
would apply and the solution would be the same, the only difference
would be in syntax.
On how to write stored procedures and triggers I would advise you
to read upon links given at and
search thru the archive of data models at

If you still have some specific questions regarding Firebird you are
welcome to post them here.