<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">

<cftry>
<cfset targetBusinessID = 44>

<cfquery name="qUpdate" datasource="payfrit">
  UPDATE Beacons
  SET BusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#targetBusinessID#">
</cfquery>

<cfquery name="qCount" datasource="payfrit">
  SELECT COUNT(*) AS cnt FROM Beacons WHERE BusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#targetBusinessID#">
</cfquery>

<cfoutput>#serializeJSON({ "OK": true, "MESSAGE": "All beacons reassigned to BusinessID #targetBusinessID#", "COUNT": qCount.cnt })#</cfoutput>

<cfcatch type="any">
  <cfoutput>#serializeJSON({ "OK": false, "ERROR": cfcatch.message })#</cfoutput>
</cfcatch>
</cftry>
