久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='OVtQq'></tfoot>

    <legend id='OVtQq'><style id='OVtQq'><dir id='OVtQq'><q id='OVtQq'></q></dir></style></legend>

      <bdo id='OVtQq'></bdo><ul id='OVtQq'></ul>
  1. <small id='OVtQq'></small><noframes id='OVtQq'>

      <i id='OVtQq'><tr id='OVtQq'><dt id='OVtQq'><q id='OVtQq'><span id='OVtQq'><b id='OVtQq'><form id='OVtQq'><ins id='OVtQq'></ins><ul id='OVtQq'></ul><sub id='OVtQq'></sub></form><legend id='OVtQq'></legend><bdo id='OVtQq'><pre id='OVtQq'><center id='OVtQq'></center></pre></bdo></b><th id='OVtQq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OVtQq'><tfoot id='OVtQq'></tfoot><dl id='OVtQq'><fieldset id='OVtQq'></fieldset></dl></div>
    1. MySQL - 插入后更新同一個表的觸發(fā)器

      MySQL - Trigger for updating same table after insert(MySQL - 插入后更新同一個表的觸發(fā)器)

          <tbody id='snjiI'></tbody>
        • <bdo id='snjiI'></bdo><ul id='snjiI'></ul>
        • <small id='snjiI'></small><noframes id='snjiI'>

          <legend id='snjiI'><style id='snjiI'><dir id='snjiI'><q id='snjiI'></q></dir></style></legend>
        • <tfoot id='snjiI'></tfoot>
          <i id='snjiI'><tr id='snjiI'><dt id='snjiI'><q id='snjiI'><span id='snjiI'><b id='snjiI'><form id='snjiI'><ins id='snjiI'></ins><ul id='snjiI'></ul><sub id='snjiI'></sub></form><legend id='snjiI'></legend><bdo id='snjiI'><pre id='snjiI'><center id='snjiI'></center></pre></bdo></b><th id='snjiI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='snjiI'><tfoot id='snjiI'></tfoot><dl id='snjiI'><fieldset id='snjiI'></fieldset></dl></div>

                本文介紹了MySQL - 插入后更新同一個表的觸發(fā)器的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                這是我想要做的:

                當(dāng)表 ACCOUNTS 中有一個新的 INSERT 時(shí),我需要更新 ACCOUNTS 中的行,其中 pk = NEW.edit_on 通過設(shè)置 status='E' 來表示特定(舊)帳戶已被編輯.

                When there's a new INSERT into the table ACCOUNTS, I need to update the row in ACCOUNTS where pk = NEW.edit_on by setting status='E' to denote that the particular (old) account has been edited.

                DELIMITER $$
                
                DROP TRIGGER IF EXISTS `setEditStatus`$$
                CREATE TRIGGER `setEditStatus` AFTER INSERT on ACCOUNTS
                FOR EACH ROW BEGIN
                    update ACCOUNTS set status='E' where ACCOUNTS.pk = NEW.edit_on ;
                END$$
                
                DELIMITER ;
                

                要求不是我操作新插入的列,而是已經(jīng)存在的列,pk = NEW.edit_on

                The requirement is NOT that I manipulate the newly inserted column, but an already existing column with pk = NEW.edit_on

                但是,我無法更新同一張表:無法更新表 ACCOUNTS ... 已被調(diào)用此觸發(fā)器的語句使用

                However, I can't update the same table: Can't update table ACCOUNTS ... already used by the statement that invoked this trigger

                請?zhí)岢鼋鉀Q方法

                PS:我已經(jīng)完成了更新表格在同一個表上更新后的觸發(fā)器,插入同一個表觸發(fā)器mysql, 在同一個表上插入后觸發(fā)器更新和 mysql 觸發(fā)器在表上插入后插入和更新 但他們似乎沒有回答我的問題.

                PS: I have already gone through Updating table in trigger after update on the same table, Insert into same table trigger mysql, Update with after insert trigger on same table and mysql trigger with insert and update after insert on table but they dont seem to answer my question.

                編輯

                ACCOUNTS 表:

                CREATE TABLE  `ACCOUNTS` (
                  `pk` bigint(10) unsigned NOT NULL AUTO_INCREMENT,
                  `user_id` bigint(9) unsigned NOT NULL,
                  `edit_on` bigint(10) unsigned DEFAULT NULL,
                  `status` varchar(1) NOT NULL DEFAULT 'A',
                  PRIMARY KEY (`pk`) USING BTREE) ENGINE=InnoDB AUTO_INCREMENT=2147483726 DEFAULT CHARSET=latin1
                

                推薦答案

                似乎無法在觸發(fā)器中完成所有這些操作.根據(jù)文檔:

                It seems that you can't do all this in a trigger. According to the documentation:

                在存儲函數(shù)或觸發(fā)器中,不允許修改已被調(diào)用函數(shù)或觸發(fā)器的語句使用(讀取或?qū)懭?的表.

                Within a stored function or trigger, it is not permitted to modify a table that is already being used (for reading or writing) by the statement that invoked the function or trigger.

                根據(jù) 這個答案,看來你應(yīng)該:

                創(chuàng)建一個存儲過程,插入/更新目標(biāo)表,然后更新其他行,所有這些都在一個事務(wù)中.

                create a stored procedure, that inserts into/Updates the target table, then updates the other row(s), all in a transaction.

                使用存儲過程,您將手動提交更改(插入和更新).我還沒有在 MySQL 中做過這個,但是這篇文章看起來不錯示例.

                With a stored proc you'll manually commit the changes (insert and update). I haven't done this in MySQL, but this post looks like a good example.

                這篇關(guān)于MySQL - 插入后更新同一個表的觸發(fā)器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) N 個先前值來決定接下來的 N 個行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數(shù)的 ignore 選項(xiàng)是忽略整個事務(wù)還是只是有問題的行?) - IT屋-程序員軟件開發(fā)技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時(shí)出錯,使用 for 循環(huán)數(shù)組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調(diào)用 o23.load 時(shí)發(fā)生錯誤 沒有合適的驅(qū)動程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫表作為 Spark 數(shù)據(jù)幀讀取?)
                <i id='oPOjH'><tr id='oPOjH'><dt id='oPOjH'><q id='oPOjH'><span id='oPOjH'><b id='oPOjH'><form id='oPOjH'><ins id='oPOjH'></ins><ul id='oPOjH'></ul><sub id='oPOjH'></sub></form><legend id='oPOjH'></legend><bdo id='oPOjH'><pre id='oPOjH'><center id='oPOjH'></center></pre></bdo></b><th id='oPOjH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='oPOjH'><tfoot id='oPOjH'></tfoot><dl id='oPOjH'><fieldset id='oPOjH'></fieldset></dl></div>
              1. <tfoot id='oPOjH'></tfoot>
                  <tbody id='oPOjH'></tbody>

                  <small id='oPOjH'></small><noframes id='oPOjH'>

                        <bdo id='oPOjH'></bdo><ul id='oPOjH'></ul>
                          <legend id='oPOjH'><style id='oPOjH'><dir id='oPOjH'><q id='oPOjH'></q></dir></style></legend>
                        • 主站蜘蛛池模板: 欧一区| 97伊人 | 一区二区三区四区不卡视频 | 日韩成人在线播放 | 天堂国产 | 国产高清在线精品一区二区三区 | 国产成人精品综合 | 精精国产xxxx视频在线播放 | 久久成| 欧洲精品视频一区 | 81精品国产乱码久久久久久 | 日韩一二区在线观看 | 99视频在线免费观看 | 欧美成人a∨高清免费观看 91伊人 | 中文字幕在线中文 | 国产在线不卡 | 韩国精品在线观看 | 欧美日韩福利视频 | 欧美综合在线视频 | 情侣av| 欧美一级片在线 | 精品网| 欧美日韩国产在线 | 国产99免费视频 | 99re热精品视频 | 97在线观视频免费观看 | 国产精品乱码一区二区三区 | 91av视频| 你懂的在线视频播放 | 91精品国产乱码久久久久久 | 国产性生活一级片 | 国产精品免费小视频 | 国产亚洲精品区 | 精品一区二区三区入口 | 精品99爱视频在线观看 | 国产极品粉嫩美女呻吟在线看人 | 日韩精品一区在线 | 成人一区二区视频 | 国产99久久| 无码一区二区三区视频 | 日日摸日日添日日躁av |