Subject RE: [firebird-support] Re: Auto Generate nos. but trigger won't work
Author Alan McDonald
> Hypothetical: If I am not mistaken as soon as I request a new record from

You don't request a new record from the server, you create a record insert
statement at the client. You can ask the server for a new record PK though,
first, then insert this new record you are constructing at the client with
the requested PK value. You know after asking the server for this PK value
that it will never be refused insertion to the DB since it has an
unequivocal PK value. And it will never be handed out to anyone else.

> FB assuming the trigger is firing then an ID should be returned
> at least on
> the server. Now for eg. I do not refresh nor do I ask for a new id and I
> try to save my record in VFP and it raises an error and nothing
> happens. Now when I open the generator and check it's value in
> Marathon I
> expect the value to have incremented, which is not the case.

generator values are generated outside all transaction control. You ask for
and it's gone whether you use it or not, it's gone.. never to be returned to
anyone else who askks for a generated value. This needs to be imutable in
your design, don't go down the track of being tempted to reset generator
values at your leisure or when you think you'd like to. That's the main
reason why PK values should be meaningless to your app. Gaps in the running
order of PK values are of absolutely no conseqence.

>
> Factual: If I ask the server for a new record, the trigger fires
> but I have
> not refreshed the data and I ask for a new id manually (as I do now) then
> every time I call the generator manually I should be expecting
> interleaved
> nos. (1 generated by the trigger, 2 manually, next record, 3 by the
> trigger, 4 manually). Even this is not the case. I have just confirmed
> that the trigger is not firing and only my manually retrieved ids are
> actually being generated and thus they are sequential nos. 1, 2, 3...
>

You would need to show us the trigger you are using. What you are describing
is possible only if you are sending the server a value - not NULL - which is
therefore not requesting a generated value since you have a not null if
cluse on your trigger.
let's see it.
Alan