Claim your Biolink Click Here
3 like 0 dislike
1.5k views

Value is not coming in @id as how to concat id variable in query

DELIMITER $$

CREATE TRIGGER update_trigger
AFTER INSERT ON asterisk.queue_log
FOR EACH ROW
BEGIN


 SET @id = (select callid from asterisk.queue_log where event="TRANSFER" and callid=(select callid from asterisk.queue_log
order by id desc limit 1));

SET @agentid = (select agent from asterisk.queue_log where event="TRANSFER" and callid=(select callid from
asterisk.queue_log order by id desc limit 1));

update Feedback.Feedback_Data set Agent_Id=@agentid where Call_Id=@id;

END $$
DELIMITER ;
in Education & Reference by (1.6k points) | 1.5k views

1 Answer

0 like 0 dislike
There are two methods, first you can run trigger like below

DELIMITER $$
    CREATE TRIGGER Feedback
    AFTER INSERT ON queue_log
    FOR EACH ROW
    BEGIN
    DECLARE v_id varchar(32);
    DECLARE v_agentid varchar(32);
    SELECT callid, agent INTO v_id, v_agentid
    FROM queue_log
    WHERE event="TRANSFER"
    ORDER BY id desc limit 1;

    update Feedback_Data set Agent_Id=v_agentid where Call_Id=v_id;

    END $$
 DELIMITER ;

 

And the other method is calling external program and do what you want below is the way

http://answergig.com/798/how-to-execute-call-an-external-program-from-mysql-trigger?
by (830 points)

Related questions

2 like 0 dislike
3 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Jul 25, 2013 in Education & Reference by Marc (4.7k points) | 804 views
0 like 0 dislike
1 answer
2 like 0 dislike
1 answer
1 like 0 dislike
1 answer

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

1,312 questions
1,473 answers
569 comments
4,809 users