I have put table name as Table_Name, which is actual table name. On Wednesday, 9 August 2017 3:27 PM, Vishal Tiwari <vishuals...@yahoo.co.in> wrote:
Hi Paul, I am getting below error while executing the trigger you shared. May be because of new FB version? I am executing using FlamRobin tool. Please see error below: *** IBPP::SQLException ***Context: Statement::Prepare( create trigger before update on Table_Nameasbeginif (new.col3 is distinct from old.col3)then new.col5 = current_timestamp )Message: isc_dsql_prepare failed SQL Message : -104can't format message 13:896 -- message file C:\Windows\system32\firebird.msg not found Engine Code : 335544569Engine Message :Dynamic SQL ErrorSQL error code = -104Token unknown - line 1, column 23update On Wednesday, 9 August 2017 3:15 PM, "Paul Vinkenoog p...@vinkenoog.nl [firebird-support]" <firebird-support@yahoogroups.com> wrote: Hello Vishal, > I have one table say "MyTable", which has five columns, say Col1, > Col2,...,Col5 and it has 10 rows. Col5 is of Timestamp. > > My issue is, whenever I am updating Col3, that time, only for that row > of Col5, Timestamp value should be updated to the current timestamp. > > What would be the best option for this? > > If trigger is the best way then how would I do it? As I never worked > on Triggers. Yes, a trigger is definitely the way to go, e.g. like this: set term #; create trigger before update on MyTable as begin if (new.col3 is distinct from old.col3) then new.col5 = current_timestamp; end# set term ;# If col3 is non-nullable you can simply use "new.col3 <> old.col3" in the test. Mind you, an explicit update that re-enters the existing value in col3 won't cause col5 to be updated! HTH, Paul Vinkenoog #yiv2712576062 -- #yiv2712576062ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv2712576062 #yiv2712576062ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv2712576062 #yiv2712576062ygrp-mkp #yiv2712576062hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv2712576062 #yiv2712576062ygrp-mkp #yiv2712576062ads {margin-bottom:10px;}#yiv2712576062 #yiv2712576062ygrp-mkp .yiv2712576062ad {padding:0 0;}#yiv2712576062 #yiv2712576062ygrp-mkp .yiv2712576062ad p {margin:0;}#yiv2712576062 #yiv2712576062ygrp-mkp .yiv2712576062ad a {color:#0000ff;text-decoration:none;}#yiv2712576062 #yiv2712576062ygrp-sponsor #yiv2712576062ygrp-lc {font-family:Arial;}#yiv2712576062 #yiv2712576062ygrp-sponsor #yiv2712576062ygrp-lc #yiv2712576062hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv2712576062 #yiv2712576062ygrp-sponsor #yiv2712576062ygrp-lc .yiv2712576062ad {margin-bottom:10px;padding:0 0;}#yiv2712576062 #yiv2712576062actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv2712576062 #yiv2712576062activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv2712576062 #yiv2712576062activity span {font-weight:700;}#yiv2712576062 #yiv2712576062activity span:first-child {text-transform:uppercase;}#yiv2712576062 #yiv2712576062activity span a {color:#5085b6;text-decoration:none;}#yiv2712576062 #yiv2712576062activity span span {color:#ff7900;}#yiv2712576062 #yiv2712576062activity span .yiv2712576062underline {text-decoration:underline;}#yiv2712576062 .yiv2712576062attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv2712576062 .yiv2712576062attach div a {text-decoration:none;}#yiv2712576062 .yiv2712576062attach img {border:none;padding-right:5px;}#yiv2712576062 .yiv2712576062attach label {display:block;margin-bottom:5px;}#yiv2712576062 .yiv2712576062attach label a {text-decoration:none;}#yiv2712576062 blockquote {margin:0 0 0 4px;}#yiv2712576062 .yiv2712576062bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv2712576062 .yiv2712576062bold a {text-decoration:none;}#yiv2712576062 dd.yiv2712576062last p a {font-family:Verdana;font-weight:700;}#yiv2712576062 dd.yiv2712576062last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv2712576062 dd.yiv2712576062last p span.yiv2712576062yshortcuts {margin-right:0;}#yiv2712576062 div.yiv2712576062attach-table div div a {text-decoration:none;}#yiv2712576062 div.yiv2712576062attach-table {width:400px;}#yiv2712576062 div.yiv2712576062file-title a, #yiv2712576062 div.yiv2712576062file-title a:active, #yiv2712576062 div.yiv2712576062file-title a:hover, #yiv2712576062 div.yiv2712576062file-title a:visited {text-decoration:none;}#yiv2712576062 div.yiv2712576062photo-title a, #yiv2712576062 div.yiv2712576062photo-title a:active, #yiv2712576062 div.yiv2712576062photo-title a:hover, #yiv2712576062 div.yiv2712576062photo-title a:visited {text-decoration:none;}#yiv2712576062 div#yiv2712576062ygrp-mlmsg #yiv2712576062ygrp-msg p a span.yiv2712576062yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv2712576062 .yiv2712576062green {color:#628c2a;}#yiv2712576062 .yiv2712576062MsoNormal {margin:0 0 0 0;}#yiv2712576062 o {font-size:0;}#yiv2712576062 #yiv2712576062photos div {float:left;width:72px;}#yiv2712576062 #yiv2712576062photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv2712576062 #yiv2712576062photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv2712576062 #yiv2712576062reco-category {font-size:77%;}#yiv2712576062 #yiv2712576062reco-desc {font-size:77%;}#yiv2712576062 .yiv2712576062replbq {margin:4px;}#yiv2712576062 #yiv2712576062ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv2712576062 #yiv2712576062ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv2712576062 #yiv2712576062ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv2712576062 #yiv2712576062ygrp-mlmsg select, #yiv2712576062 input, #yiv2712576062 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv2712576062 #yiv2712576062ygrp-mlmsg pre, #yiv2712576062 code {font:115% monospace;}#yiv2712576062 #yiv2712576062ygrp-mlmsg * {line-height:1.22em;}#yiv2712576062 #yiv2712576062ygrp-mlmsg #yiv2712576062logo {padding-bottom:10px;}#yiv2712576062 #yiv2712576062ygrp-msg p a {font-family:Verdana;}#yiv2712576062 #yiv2712576062ygrp-msg p#yiv2712576062attach-count span {color:#1E66AE;font-weight:700;}#yiv2712576062 #yiv2712576062ygrp-reco #yiv2712576062reco-head {color:#ff7900;font-weight:700;}#yiv2712576062 #yiv2712576062ygrp-reco {margin-bottom:20px;padding:0px;}#yiv2712576062 #yiv2712576062ygrp-sponsor #yiv2712576062ov li a {font-size:130%;text-decoration:none;}#yiv2712576062 #yiv2712576062ygrp-sponsor #yiv2712576062ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv2712576062 #yiv2712576062ygrp-sponsor #yiv2712576062ov ul {margin:0;padding:0 0 0 8px;}#yiv2712576062 #yiv2712576062ygrp-text {font-family:Georgia;}#yiv2712576062 #yiv2712576062ygrp-text p {margin:0 0 1em 0;}#yiv2712576062 #yiv2712576062ygrp-text tt {font-size:120%;}#yiv2712576062 #yiv2712576062ygrp-vital ul li:last-child {border-right:none !important;}#yiv2712576062