Jump to content
  • 0

триггеры


xaero
 Share

Question

Здравствуйте ...

для не которых таблицы я сделал тригерры. Тригеррые запустил в MySQL front и MySQL HeidiSQL там работает все классно

вот триггеры:

DELIMITER $$
DROP TRIGGER IF EXISTS `cdr_update`$$
CREATE TRIGGER `cdr_update` AFTER UPDATE ON cdr
FOR EACH ROW BEGIN
/* update crm_telephony */
UPDATE crm_telephony SET
id_zv = NEW.id_cd,
orders_id = NEW.orders_id,
man_id = NEW.man_id,
type_zv = NEW.type_zv,
telephone = NEW.telephone,
date_start = NEW.calldate,
duration = NEW.billsec,
status = NEW.disposition,
record = NEW.userfield,
comment = NEW.comment,
dest = NEW.dst
WHERE id_zv=OLD.id_cd AND type='cdr';
/* update crm_log */
UPDATE crm_log SET
log_id = NEW.id_cd,
man_id = NEW.man_id,
date_start = NEW.calldate,
date_finish = DATE_ADD(NEW.calldate, INTERVAL NEW.duration SECOND),
telephone = NEW.telephone,
dest = NEW.dst,
type = 29,
type_zv = NEW.type_zv,
action = 'view',
comment = NEW.comment,
process = 29,
orders_id = NEW.orders_id
WHERE log_id=OLD.id_cd AND process=29;
END;$$

/* insert cdr table trigger */
DELIMITER $$
DROP TRIGGER IF EXISTS `cdr_insert`$$
CREATE TRIGGER `cdr_insert` AFTER INSERT ON cdr
FOR EACH ROW BEGIN
/* insert crm_telephony */
INSERT INTO crm_telephony SET
id_zv = NEW.id_cd,
orders_id = NEW.orders_id,
man_id = NEW.man_id,
type_zv = NEW.type_zv,
type = 'cdr',
telephone = NEW.telephone,
date_start = NEW.calldate,
duration = NEW.billsec,
status = NEW.disposition,
record = NEW.userfield,
comment = NEW.comment,
dest = NEW.dst;
/* insert crm_log */
INSERT INTO crm_log SET
log_id = NEW.id_cd,
man_id = NEW.man_id,
date_start = NEW.calldate,
date_finish = DATE_ADD(NEW.calldate, INTERVAL NEW.duration SECOND),
telephone = NEW.telephone,
dest = NEW.dst,
type = 29,
type_zv = NEW.type_zv,
action = 'view',
comment = NEW.comment,
process = 29,
orders_id = NEW.orders_id;
END;$$

но когда запускаю в phpMyAdmin даёт ошибка ...?

можно ли в phpmyadmin запускать не сколько триггеров сразу ... ?

спасибо за ответы ...

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy