Subject Re: Porting from mysql to firebird
Author dleec45
> If you application needs to *know* what number is generated, then
you need
> to get the value *before* the new row is posted to the database.

Helen I too am moving a web app from MySQL to FB1.5 with about 50
tables and some tables with many relationships. In order to update
them properly, does this constitute a 'need to know *before*'
situation in order to update them properly. I have currently set the
tables up so that each has there own generator name (necessary??) and
am not sure how to do the updates when there are several child tables
attached to the parent. How and in what order does one handle this?
If samples are available somewhere that would certainly shed some
light on this.



There are
> two distinct ways to go about this...
> 1) Application writers often do a query similar to the one above,
but using
> an incrementor of 1 or greater, viz.
>
> SELECT GEN_ID(GEN_ATABLE, 1) FROM RDB$DATABASE;
> or
> 2) write a selectable stored procedure to do the same thing, viz.
> SET TERM ^;
> CREATE PROCEDURE GET_GEN_ATABLE
> RETURNS (PK_VALUE NUMERIC(18,0)) AS
> BEGIN
> PK_VALUE = GEN_ID(GEN_ATABLE, 1);
> SUSPEND;
> END ^
> COMMIT ^
> SET TERM ;^
>
> Then, your client query can just
>
> SELECT PK_VALUE FROM GET_GEN_TABLE;
>
> Helen
> p.s. PLEASE do not post HTML messages in our lists. Thks.