Subject | Re: [IBO] Question about generato management |
---|---|
Author | Marco Menardi <mmenaz@lycosmail.com> |
Post date | 2003-01-02T21:16:21Z |
I would add that you HAVE to use generatorlinks (or a client side ID
retrieve) for a master in a master-detail situation, so new detail
inserted rows will have the apropriate master ID.
In addition, Marco, I've found that the general "suggested" syntax in
triggers is:
IF (( new.ID_TEST IS NULL ) OR (new.ID_TEST < 0)) then
new.ID_TEST = GEN_ID(TEST_GEN,1);
the reason is fire the generator when you are using tools that flag
primary keys as "required", so you could not send a null value for the
key. Here, insetad, you set the ID_TEST to -1 (or whatever nevative
number) as a workaround.
regards
Marco Menardi
retrieve) for a master in a master-detail situation, so new detail
inserted rows will have the apropriate master ID.
In addition, Marco, I've found that the general "suggested" syntax in
triggers is:
IF (( new.ID_TEST IS NULL ) OR (new.ID_TEST < 0)) then
new.ID_TEST = GEN_ID(TEST_GEN,1);
the reason is fire the generator when you are using tools that flag
primary keys as "required", so you could not send a null value for the
key. Here, insetad, you set the ID_TEST to -1 (or whatever nevative
number) as a workaround.
regards
Marco Menardi
--- In IBObjects@yahoogroups.com, Marco Lauria <mslauria@s...> wrote:
> At 18.57 02/01/2003 +0100, you wrote:
> >hello,
> >
> >Happy New Year to all of you.
> >
> >I was wondering what could be the differences and benefits (if any) of
> >using the Generator_Link of an TIB_Query instead of managing the
> >generator stuff directly with appropriate triggers (as I am actually
> >doing) when inserting new rows.
> >
> >Regards
> >Salvatore
>
> If you issue a refresh after you insert a row and you fill the
generator in
> a trigger instead
> of leaving ibo filling it, ibo would not know which is the PK of the
new
> row inserted.
> I think this is the most important reason why you should use
generatorlink
> instead of managing
> it in a trigger.
> But if you don't need to be syncronized with the DB when you insert
(such
> as when you import data)
> then the faster thing is to implement generators using triggers.
> Usually I use in my trigger this syntax:
> IF ( new.ID_TEST IS NULL ) then
> new.ID_TEST = GEN_ID(TEST_GEN,1);
>
> so I am able to use both solutions basing upon my specific needs.
> Regards
> Marco
>
>
> Best Regards,
> Marco Lauria
> STARMAX s.a.s.
> TEL. +39-091-6880476
> FAX. +39-091-6887202
> MOB. +39-348-3547034
>
> [Non-text portions of this message have been removed]