Increment a Hidden Column value by +1 each time..
i have following code segment & need add in third column called ttcount that needs incremented "1"
- starts out value of "1" (when ticket created..)
- if/when ticket "re-opened", needs incremented +1
so, question how alter code below update ttcount field 1?
---------------------------------
<!--- hold off doing update unless the form has been submitted --->
<cfif isdefined("form.kt_insert1")>
<!--- update status re-opened , owner unassigned in tbltickets table --->
<cfquery datasource="care">
update tbltickets
set ttstatus=<cfqueryparam value="re-opened" cfsqltype="cf_sql_varchar">,
ttowner=<cfqueryparam value="unassigned" cfsqltype="cf_sql_varchar">
where ttnum=<cfqueryparam cfsqltype="cf_sql_varchar" value="#url.id#">
</cfquery>
</cfif>
--------------------------------
note: ttcount field hidden field follows:
<input type="hidden" name="ttcount" id="ttcount" value="1" />
i figured out using following code in bold:
---------------------------------
<!--- hold off doing update unless the form has been submitted --->
<cfif isdefined("form.kt_insert1")>
<!--- update status re-opened , owner unassigned in tbltickets table --->
<cfquery datasource="care">
update tbltickets
set ttstatus=<cfqueryparam value="re-opened" cfsqltype="cf_sql_varchar">,
ttowner=<cfqueryparam value="unassigned" cfsqltype="cf_sql_varchar">
, ttcount=<cfif isdefined("form.ttcount") , #form.ttcount# neq "">
<cfqueryparam value="#form.ttcount#" cfsqltype="cf_sql_numeric">+1
<cfelse>
null
</cfif>
where ttnum=<cfqueryparam cfsqltype="cf_sql_varchar" value="#url.id#">
</cfquery>
</cfif>
-----------------------------
More discussions in ColdFusion
adobe
Comments
Post a Comment