BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

changing a field value inside a trigger

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (InterBase Express)
View previous topic :: View next topic  
Author Message
HanslH
Guest





PostPosted: Sat Feb 03, 2007 7:58 pm    Post subject: changing a field value inside a trigger Reply with 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?
Back to top
Bill Todd
Guest





PostPosted: Sat Feb 03, 2007 8:38 pm    Post subject: Re: changing a field value inside a trigger Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (InterBase Express) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.