| View previous topic :: View next topic |
| Author |
Message |
HanslH Guest
|
Posted: Sat Feb 03, 2007 7:58 pm Post subject: changing a field value inside a trigger |
|
|
I want to have my own calculated field so I can index on it later and
thought i'd use a trigger. What sql statement can i put inside a
trigger to have field3 have the value field2-field1 if the record has
changed.
Can I actually adress the record that's changing since SQL doesn't
seem to let me touch records without some sort of filter statement? |
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Sat Feb 03, 2007 8:38 pm Post subject: Re: changing a field value inside a trigger |
|
|
HanslH wrote:
| Quote: | I want to have my own calculated field so I can index on it later and
thought i'd use a trigger. What sql statement can i put inside a
trigger to have field3 have the value field2-field1 if the record has
changed.
Can I actually adress the record that's changing since SQL doesn't
seem to let me touch records without some sort of filter statement?
|
The answer to this and the other questions you have asked are in the
Data Definition Guide. It is not that long and you will have a much
better understanding of what you can do and how to do it if you read
the book. In this case you will need a before insert and a before
update trigger with the following code.
NEW.FIELD3 = NEW.FIELD2 - NEW.FIELD1;
--
Bill Todd (TeamB) |
|
| Back to top |
|
 |
|