English 中文(简体)
我的SQL 青 works后加插,但不在文字后插入
原标题:mySQL Trigger works after console insert, but not after script insert

我有一个问题。

我在表格中插入一个字后建立了更新其他表格的触发点。

如果我从MySQL console上插入一个字句,那么所有工作都会受到罚款,但如果我确实用同一数据从外面的字典上插入,那么触发器就没有什么作用,因为你可以看到灯塔。

我试图将定义者改变为用户......%和根基...... %,但至今没有做任何事。

mysql> select vid_visit,vid_money from videos where video_id=487;
+-----------+-----------+
| vid_visit | vid_money |
+-----------+-----------+
|        21 |     0.297 |
+-----------+-----------+
1 row in set (0,01 sec)

mysql> INSERT INTO `table`.`validEvents` ( `id` , `campaigns_id` , `video_id` , `date` , `producer_id` , `distributor_id` , `money_producer` , `money_distributor` , `type` ) VALUES ( NULL ,  30 ,  487 ,  2010-05-20 01:20:00 ,  1 ,  0 ,  0.009 ,  0.000 ,  PRE  );
Query OK, 1 row affected (0,00 sec)

mysql> select vid_visit,vid_money from videos where video_id=487;                                                                  

+-----------+-----------+
| vid_visit | vid_money |
+-----------+-----------+
|        22 |     0.306 |
+-----------+-----------+

DROP TRIGGER IF EXISTS `updateVisitAndMoney`//
CREATE TRIGGER `updateVisitAndMoney` BEFORE INSERT ON `validEvents`
 FOR EACH ROW BEGIN
    if (NEW.type =  PRE ) THEN
                SET @eventcash=NEW.money_producer + NEW.money_distributor;
        UPDATE campaigns SET cmp_visit_distributed = cmp_visit_distributed + 1 , cmp_money_distributed = cmp_money_distributed + NEW.money_producer + NEW.money_distributor WHERE idcampaigns = NEW.campaigns_id;
        UPDATE offer_producer SET ofp_visit_procesed = ofp_visit_procesed + 1 , ofp_money_procesed = ofp_money_procesed + NEW. money_producer WHERE ofp_video_id = NEW.video_id AND ofp_money_procesed = NEW. campaigns_id;
        UPDATE videos SET vid_visit = vid_visit + 1 , vid_money = vid_money + @eventcash WHERE video_id = NEW.video_id;

        if (NEW.distributor_id !=   ) then
            UPDATE agreements SET visit_procesed = visit_procesed + 1, money_producer = money_producer + NEW.money_producer, money_distributor = money_distributor + NEW.money_distributor WHERE id_campaigns = NEW. campaigns_id AND id_video = NEW.video_id AND ag_distributor_id = NEW.distributor_id;
            UPDATE eventForDay SET visit = visit + 1, money = money + NEW. money_distributor WHERE date = SYSDATE()  AND campaign_id = NEW. campaigns_id AND user_id = NEW.distributor_id;
            UPDATE eventForDay SET visit = visit + 1, money = money + NEW.money_producer WHERE date = SYSDATE() AND campaign_id = NEW. campaigns_id AND user_id= NEW.producer_id;
        ELSE
            UPDATE eventForDay SET visit = visit + 1, money = money + NEW. money_producer WHERE date = SYSDATE() AND campaign_id = NEW. campaigns_id AND user_id = NEW.producer_id;
        END IF;
    END IF;
END
//
问题回答

我认为,你很有可能遇到一个无尽的错误,而不是触发因素没有执行,特别是因为它成功地从奥洛尔执行。

在发生错误时,你需要加以孤立——在触发因素本身,或在打字稿中。

在你的书本中,印刷了KQ号声明,称呼 p派到MySQL执行,以确保它按照你的期望建造,例如,如果是新兵的话。 类型并不等于购买力平价,触发器将已执行,但不会导致任何更新。

还确保你检查插入上的错误。 我不是一位Python方案家,因此,我可以告诉你,这是怎样做的,但 似乎就是你所期待的。

如果两者都不会导致问题,就整个<代码>(NEW.type = PRE)发表评论,说明N栏目,并作简单的改动,如设置新字。 type . 在确保触发器实际上能够执行之后,在你孤立这一问题之前,随着更多实际代码的重新测试,重新测试。

而且,rt马科斯评论说,如果说稿在成功完成后就自动承诺,我将感到惊讶。 事实上,我要就任何文字/语言作此发言。

For anyone finding this question in the future - I am guessing the solution is setting mysql autocommit to true. after opening the connection query the following:

SET 汽车

壳牌指挥只在奥列,而不是在实际服务器上运行。 你们可以利用民主力量联盟或投票来完成你们的需要。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签