|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have an Date field which I would like to have populated every time a record is inserted.
Is it best to do this in a trigger or via stored proc? Trigger: UPDATE GOOD_SAYINGS SET GOOD_DATE =CURRENT_TIMESTAMP WHERE ID = ' How to get the lastest ID as this is a after insert trigger'; I will need to get the latest ID field to add a where clause. How would be the best method for this? ![]() |
|
#2
|
||||
|
||||
|
Is the trigger updating a field in the same table that is updated by the triggering sql statement?
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
|
#3
|
|||
|
|||
|
Quote:
Not yet but could if the trigger is the way to go. I thinking of populating the date field after insert. I guess the answer would be yes as the trigger is updating the field is this a good idea? ![]() |
|
#4
|
||||
|
||||
|
In this case you can use an "before update" or "before insert" trigger to set the new value for the column
|
|
#5
|
||||
|
||||
|
Trigger is the way to go!
See my blog for an example. Last edited by pabloj : March 18th, 2006 at 04:10 PM. |
|
#6
|
|||
|
|||
|
Quote:
Nice example thanks! ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Trigger or no Trigger |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|