Subject Re: [IBO] Trigger not being called
Author Helen Borrie
At 01:30 AM 25/02/2003 +0000, you wrote:
>Hi there,
>
>I know I have read the solution to this before, but I can't find it
>now.
>
>I have both a before-insert and a before-update trigger for a table
>which ensures another field in the table maintains an upper-case
>version of the field in question.
>
>NAME is the field of the table, and UPNAME is the uppercase version.
>The user never see's the UPNAME, it is maintained purely by the
>server.
>
>BTW, using IBO 4.2I.
>
>When I go to insert a new field in my app, I am being told that
>UPNAME is a required field. Why does it seem that the trigger in the
>background is not being fired?

Triggers are not fired by Delphi. They are a server action that occurs
when the new recversion reaches the server (i.e. it is posted) - the client
cannot make them fire. At the point where your dataset is in dssInsert or
dssEdit, the server knows nothing about it. Don't confuse Delphi events
like BeforeInsert with Before Insert triggers on the server...they are
totally unconnected.

The Required Field exception occurs on the client side, before the Post,
when IBO checks that there are values in all of the non-nullable fields of
the query. It knows about all non-nullable columns because this is one of
the pieces of information it gets and stores when it performs a Prepare.

You have two ways to bypass this:

1. Simplest: don't include the field in your query, unless you need it
there for some reason (e.g. as a search key)

2. Set the field's REQUIRED property to false. You can set it directly in
the query editor if you are using the TIB_ components (see
ColumnAttributes); you can set it in the ColumnAttributes property of the
IBODatabase or IB_Connection with fetSQLType included in the
FieldEntryTypes[] set (MYTABLE.UPNAME=REQUIRED=FALSE). You can also set
ColumnAttributes properties in run-time code - see the TI Sheet "Working
with Datasets".

>I know it has something to do with an IBO param, but cannot locate
>it.

Not that I know of. Are you confusing this with a technique to set a
parameter value to NULL? (ParamByName('MyParam').Clear)

Helen