My personal best practices for update queries in custom ticket rules. Might save you some DB restores in future.

I have started adding LIMIT 1 to the bottom of the update query as a fail safe when using ticket rules when I am expecting to only update 1 ticket. If you know why... you know why. :) 

For visual here is a simple update query using the example from the little blue help icon above the update query when creating/editing a ticket rule.
The help icon states that the below QUERY 1 will be changed to QUERY2 when executed.
I add one line to the bottom of that seen underlined in QUERY 3 which will save you from accidentally updating every ticket on accident. 

**** QUERY 1 ****
update HD_TICKET
set TITLE = 'changed'

**** QUERY 2 ****
update HD_TICKET
set TITLE = 'changed'
where HD_TICKET.ID in (1,2,3)

**** QUERY 3 ****
update HD_TICKET
set TITLE = 'changed'

Here is a screenshot of this in action with before and after results from MySQL Workbench and the results from Last Run Log for confirmation. I also highlighted with a red arrow that the select query did indeed return 4 id's.
Ideally you would want to pass ONLY the ID's to the update query that you want to perform an update on. Again this is just a safety measure I use for myself that others might be find useful. 



This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ