<div dir="ltr">bill_event() charges atomically:<br><br>sql = dsql = switch_mprintf(&quot;UPDATE %s SET %s=%s-%f WHERE %s=&#39;%s&#39;&quot;, globals.db_table, globals.db_column_cash, <wbr>globals.db_column_cash, billamount, globals.db_column_account, billaccount);<div><br></div><div>That UPDATE query won&#39;t conflict with any other queries running at the same time, they&#39;ll lock on each other so one updates the row at a time.<br><div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">The balance fetched by get_balance isn&#39;t used to update the balance so it shouldn&#39;t matter if there are multiple calls. Both will use UPDATE and overlapping calls will update the balance correctly. They&#39;ll then both spot if the balance drops below the minimum.                </span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 September 2016 at 05:50, Mohd Kamal Mustafa <span dir="ltr">&lt;<a href="mailto:kamal@xoxzo.com" target="_blank">kamal@xoxzo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If not, is there a possibilities of reach condition where updates from<br>
multiple channels override each other. For example, 2 incoming calls<br>
at the same time to 2 different numbers, but owned by single user -<br>
that mean nibble will be updating the same record in database.<br>
<br>
I&#39;m planning to add &quot;FOR UPDATE&quot; clause to the custom_sql_lookup:-<br>
<br>
SELECT cash AS nibble_balance FROM accounts WHERE<br>
account_code=&#39;${nibble_account<wbr>} FOR UPDATE<br>
<br>
But if each query run inside their own transaction, that would be no use.<br>
<br>
Thank you.<br>
<br>
______________________________<wbr>______________________________<wbr>_____________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.freeswitchsolutions<wbr>.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.o<wbr>rg</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswi<wbr>tch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/ma<wbr>ilman/listinfo/freeswitch-user<wbr>s</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.frees<wbr>witch.org/mailman/options/<wbr>freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br></div></div></div>