

#Mysql insert on duplicate key update update
ON DUPLICATE KEY UPDATE agentStatus = "READY", timestamp = FROM_UNIXTIME(NEW.time), callid = NULL Ĭallduration = replace(substring(substring_index(NEW.data, ‘|’, 3), length(substring_index(NEW.data, ‘|’, 3 - 1)) + 1), ‘|’, ‘’)

Where callid = NEW.callid INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,NEW.event,FROM_UNIXTIME(NEW.time),NULL) OriginalPosition = replace(substring(substring_index(NEW.data, ‘|’, 3), length(substring_index(NEW.data, ‘|’, 3 - 1)) + 1), ‘|’, ‘’), ON DUPLICATE KEY UPDATE agentStatus = NEW.event, timestamp = FROM_UNIXTIME(NEW.time), callid = NEW.callid ĮLSEIF NEW.event in (‘COMPLETECALLER’,‘COMPLETEAGENT’) THEN Where callid = NEW.callid INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,NEW.event, FROM_UNIXTIME(NEW.time), NEW.callid) UPDATE call_status SET callid = NEW.callid, status = NEW.event, timestamp = FROM_UNIXTIME(NEW.time), queue = NEW.queuename, ON DUPLICATE KEY UPDATE agentStatus = “PAUSE”, timestamp = FROM_UNIXTIME(NEW.time), callid = NULL INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,‘PAUSE’,FROM_UNIXTIME(NEW.time),NULL) ON DUPLICATE KEY UPDATE agentStatus = “LOGGEDOUT”, timestamp = FROM_UNIXTIME(NEW.time), callid = NULL INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,‘LOGGEDOUT’,FROM_UNIXTIME(NEW.time),NULL)

ON DUPLICATE KEY UPDATE agentStatus = “READY”, timestamp = FROM_UNIXTIME(NEW.time), callid = NULL INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,‘READY’,FROM_UNIXTIME(NEW.time),NULL) bi_queueEvents BEFORE INSERT ON asterisk. = Agent ‘1000’ logged in (format ulaw/ulaw) WARNING: config.c:2018 find_engine: Realtime mapping for ‘queue_log’ found to engine ‘mysql’, but the engine is not available – Started music on hold, class ‘default’, on SIP/1000-00000003 – Playing ‘agent-loginok.gsm’ (language ‘en’) But its not going to DB though the entries are there in the ‘/var/log/asterisk/queue_log’. I want to log the queue_log data in to mysql DB. I guess i could run each query separately (like phpMyAdmin?) but it's going to be a lot of queries so i really want to avoid that.I have asterisk 1.6.2.22 installed on my centOS. If there is another way of doing an "update if exists, otherwise insert" query on multiple fields with two keys, i'm up for other ideas too. The problem is in the question marks, what should i put there so that each insert/update will have the correct value? Obviously if i put a value there all the fields will get that value. I prefer this but i'm not sure how i can change the value on the update for each value. Something like this would be good too but i will need to have different values for each item. With phpMyAdmin a query like this works fine but i'm guessing it's running the queries independently as it prints out the results from that query as comments? This all works fine but i get an error on the second insert. I want to do something like this INSERT INTO t (t.a, t.b, t.c)
