Subject Re: [firebird-support] [RE: firebird-support] average cost price - using SP's
Author Peter Sanders
Hi Maya

On Tue, 23 Nov 2004 08:34:41 +0200, Maya McLeod <maya@...>
wrote:

>>> Delphi and a database called Flashfiler (a record based C/S DB).
>
> We use Delphi too - except we used to use paradox. I could NEVER go back
> now!

Flashfiler is much better than Paradox, much like I guess FB is much
better than Flashfiler.

>>> I have a lot to learn about FB
>
> Do yourself a favour and get Helen's book (The Firebird Book) if you
> haven't already. It will save you many hours of your time, not to
> mention headaches.

Concidentally I just contacted a local bookstore about that very book.

> I would be interested to know what Delphi components you decided to use
> for accessing FB.

Initially I will use Delphi's IBX components. This will get me started and
mor familiar with FB. I have seen an d/l IBObjects. After an initial
surprise at the number of components and wondering where to begin, I did
try it out. IBOjects AFAICS will be the way to go - but I prefer to be a
little more familiar with FB before I commit to IBO. After becomming more
conversant with FB I may then see something more "in tune" with my needs.

> SP's can be used for many things. Only your imagination is your limit ;-)
> I started off using selectable SP's much as one would use a view, and
> then just extended things from there.
[...]
> So as you can see, asking "what can you do with stored procedures?" is a
> bit like asking "what can you do with C++?" - OK, maybe not quite as
> powerful as C or Delphi, etc, but you get the picture?

Yes :D

> I use stored procedures as a base for all my reports.
> Totals are not stored, but calculated as needed (if you get your indices
> right, then speed is not a problem) No need for 'rebuilds' to correct
> total field that have gone out of synche.
>
> If you are going to write SP's then, I recommend you use a tool such as
> IBExpert to do this. Yes, it is possible to write them in Notepad, but
> try IBExpert (Personal Ed is free), and you'll see what I'm talking
> about. There is code-completion, sysntax highlighting, compiling, etc -
> all of those niceties that us Delphi programmers are used to.

Yes, I came across IBExpert and was VERY impressed with the abilities of
the personal edition.

> Below is a sample procedure:
[...]
> I probably shouldn't be calling exit's (like you shouldn't in delphi
> either...)
>
> ------------------------------------------------------------------
>
> CREATE PROCEDURE CALC_STOCK_FIFO_COST (
> ISTOCKCODE VARCHAR(30) CHARACTER SET NONE,
> IWAREHOUSECODE VARCHAR(4) CHARACTER SET NONE,
> ITODATE TIMESTAMP)
> RETURNS (
> OLEVEL DECIMAL(18,5),
> OEXTCOST DECIMAL(18,5))
> AS
> DECLARE VARIABLE LLEVEL DECIMAL(18,5);
> DECLARE VARIABLE LCOSTPRICE DECIMAL(18,5);
> DECLARE VARIABLE LCOSTPRICEPER DECIMAL(18,5);
> DECLARE VARIABLE LQTY DECIMAL(18,5);
> begin
[...]
> ------------------------------------------------------------------
> OK, OK, that one might scare you away for life:

Yes :d

> Here is the simplest one I could find:
>
> (This is probably the kind of thing you would start off with)
>
> ------------------------------------------------------------------
> CREATE PROCEDURE LIST_UOM_USED
> RETURNS (
> OUOM VARCHAR(5) CHARACTER SET NONE)
> AS
[...]
> end
> end

Better :D

I guess it is just a matter of understanding the syntax and language
keywords etc. This will come with a little (LOT?) of practice.

> ------------------------------------------------------------------
>
> NB. You'll probably be able to convert you app without touching SP's (as
> you never had them before)

Yes, that's a good point.

> but as you develop, and enhance stuff, you'll find more and more use for
> them.
>
> Hope this helps.

Yes, it does. I wish I could just make the change now. However I will have
to wait a little while yet - while I practice :D

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/