Subject Re: [IBO] Stored Procedure or Trigger
Author Lucas Franzen
Freddy Holst Christensen schrieb:
> HEY All
> I'm a newbie just starting to use InterBase and IB Objects
> And now I have a question, which I hope you can advise me on.
> When adding records to a table, what approch works best, to get the next
> record ID-number:
> Using a stored procedure or a trigger.

If you don't want to do it on the client side (with GeneratorLinks)
there's only one way to do it: in a before insert trigger for the table.

Triggers will be executed automatically, stored procedures have to be
executed explicitely.
So, if you use a stored procedure for that, you'll have to write a
either triger that will execute it or execute this procedure from the
client side to supply a value.

Stored Procs and Triggers share the same language, but keep the big
difference in mind:

TRIGGERS will fire (when not set to inactive) when the action
(BEFORE|AFTER, INSERT|UPDATE|DELETE) on the table, they're defined for
occurs and you can't define any parameters for triggers. You can't
execute a trigger without the appropriate action on the table.

Stored Procedures will be called explicitely, they can have in- and
output parameters. SPs might be executed from triggers, but they aren't
able to execute triggers (unless the procedure will insert/update/delte
records from a table which might fire a trigger ....)