Subject | RE: [firebird-support] "beginners" question |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-06-15T09:49:57Z |
>Thank you in advance for your patience.That's your job, Olaf, Firebird might give an error message after a while, but it cannot protect itself against careless programming.
>
>
>I want to dive deeper into the basics of firebird. It does not look like so,
>but I have created a lot in firebird ;o)
>
>Well, I have a table with an update-trigger. At a specified value I can set
>"new.value = somevalue" okay.
>
>If I must change some data for example: (if all records have the value of
>XX, condition new.valueofsomefiled), then:
>
>Update sametable set statusfield = XX where condition = XX.
>
>How protects firebird itself for running an endless loop? (the update
>trigger updates the table and normally the update of the update runs a
>update .
In your example, I'd just change the query a little bit:
Update sametable set statusfield = XX where condition = XX and statusfield is distinct from XX
(I generally use an old Firebird version, but I think 'is distinct from' is identical to (statusfield is null or statusfield <> XX) in newer versions)
Of course, if you have one trigger modifying statusfield from XX to YY and another from YY to XX, then you have to think a bit deeper to solve the problem of infinite recursion ;o)
HTH,
Set