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

<tfoot id='HVhVQ'></tfoot>

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

      <i id='HVhVQ'><tr id='HVhVQ'><dt id='HVhVQ'><q id='HVhVQ'><span id='HVhVQ'><b id='HVhVQ'><form id='HVhVQ'><ins id='HVhVQ'></ins><ul id='HVhVQ'></ul><sub id='HVhVQ'></sub></form><legend id='HVhVQ'></legend><bdo id='HVhVQ'><pre id='HVhVQ'><center id='HVhVQ'></center></pre></bdo></b><th id='HVhVQ'></th></span></q></dt></tr></i><div id='HVhVQ'><tfoot id='HVhVQ'></tfoot><dl id='HVhVQ'><fieldset id='HVhVQ'></fieldset></dl></div>
      • <bdo id='HVhVQ'></bdo><ul id='HVhVQ'></ul>

      我可以将 :OLD 和 :NEW 伪记录复制到 Oracle 存储过程中吗?

      时间:2023-10-26
        <tbody id='h9XCa'></tbody>
    1. <tfoot id='h9XCa'></tfoot>
      <legend id='h9XCa'><style id='h9XCa'><dir id='h9XCa'><q id='h9XCa'></q></dir></style></legend>
    2. <small id='h9XCa'></small><noframes id='h9XCa'>

        • <bdo id='h9XCa'></bdo><ul id='h9XCa'></ul>

            • <i id='h9XCa'><tr id='h9XCa'><dt id='h9XCa'><q id='h9XCa'><span id='h9XCa'><b id='h9XCa'><form id='h9XCa'><ins id='h9XCa'></ins><ul id='h9XCa'></ul><sub id='h9XCa'></sub></form><legend id='h9XCa'></legend><bdo id='h9XCa'><pre id='h9XCa'><center id='h9XCa'></center></pre></bdo></b><th id='h9XCa'></th></span></q></dt></tr></i><div id='h9XCa'><tfoot id='h9XCa'></tfoot><dl id='h9XCa'><fieldset id='h9XCa'></fieldset></dl></div>
                本文介绍了我可以将 :OLD 和 :NEW 伪记录复制到 Oracle 存储过程中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个 AFTER INSERT OR UPDATE OR DELETE 触发器,我正在编写它以通过复制 INSERTUPDATE :NEW 值到镜像表中,对于 DELETE:OLD 值.

                I have an AFTER INSERT OR UPDATE OR DELETE trigger that I'm writing to store every record revision that occurs in a certain table, by copying the INSERT and UPDATE :NEW values into a mirror table, and for DELETE the :OLD values.

                通过有条件地将 :NEW:OLD 记录传递到一个过程中,然后该过程将插入到我的历史记录表中,我可以大大简化我的代码.不幸的是,我似乎找不到传递整个 :OLD:NEW 记录的方法.

                I could un-clutter my code considerably by conditionally passing either the :NEW or :OLD record into a procedure which would then do the insert into my history table. Unfortunately I cannot seem to find a way to pass the entire :OLD or :NEW record.

                我是不是遗漏了什么,或者在调用插入过程时没有办法避免枚举每个 :NEW:OLD 列?

                Am I missing something or is there no way to avoid enumerating every :NEW and :OLD column as I invoke my insert procedure?

                我想做以下事情:

                DECLARE
                  PROCEDURE LOCAL_INSERT(historyRecord in ACCT.ACCOUNTS%ROWTYPE) IS
                  BEGIN
                    INSERT INTO ACCT.ACCOUNTS_HISTORY (ID, NAME, DESCRIPTION, DATE) VALUES (historyRecord.ID, historyRecord.NAME, historyRecord.DESCRIPTION, SYSDATE);
                  END;
                BEGIN
                  IF INSERTING OR UPDATING THEN
                    LOCAL_INSERT(:NEW);
                  ELSE --DELETING
                    LOCAL_INSERT(:OLD);
                  END IF;
                END;
                

                但我坚持这样做:

                DECLARE
                  PROCEDURE LOCAL_INSERT(id in ACCT.ACCOUNTS.ID%TYPE,
                                         name in ACCT.ACCOUNTS.NAME%TYPE,
                                         description in ACCT.ACCOUNTS.DESCRIPTION%TYPE) IS
                  BEGIN
                    INSERT INTO ACCT.ACCOUNTS_HISTORY (ID, NAME, DESCRIPTION, DATE) VALUES (id, name, description, SYSDATE);
                  END;
                BEGIN
                  IF INSERTING OR UPDATING THEN
                    LOCAL_INSERT(:NEW.ID, :NEW.NAME, :NEW.DESCRIPTION);
                  ELSE --DELETING
                    LOCAL_INSERT(:OLD.ID, :OLD.NAME, :OLD.DESCRIPTION);
                  END IF;
                END;
                

                好的,所以它看起来没有太大区别,但这只是一个包含 3 列而不是几十列的示例.

                Okay, so it doesn't look like a big difference, but this is just an example with 3 columns rather than dozens.

                推荐答案

                不是.你必须自己通过枚举来完成.

                It isn't. You have to do it yourself through enumeration.

                它不能/不能自动工作的原因包括:

                The reasons it can't/doesn't work automatically include:

                • :old:new 是默认约定;您可以通过 CREATE TRIGGERREFERENCING 子句将 :old:new 引用命名为您想要的任何内容> 声明.

                • the :old and :new are default conventions; you can name the :old and :new references to be whatever you want through the REFERENCING clause of the CREATE TRIGGER statement.

                您必须有一个类型的公共声明(通过CREATE TYPE 或通过包声明)才能将其用作另一段代码的参数.

                you'd have to have a public declaration of a type (through CREATE TYPE or through a package declaration) to be able to use it as an argument to another piece of code.

                触发代码是解释代码,不是编译代码.

                trigger code is interpreted code, not compiled code.

                这篇关于我可以将 :OLD 和 :NEW 伪记录复制到 Oracle 存储过程中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Python - pyodbc 调用带有参数名称的存储过程 下一篇:是否可以从 Ruby 调用 MySQL 存储过程?

                相关文章

                1. <i id='1QVer'><tr id='1QVer'><dt id='1QVer'><q id='1QVer'><span id='1QVer'><b id='1QVer'><form id='1QVer'><ins id='1QVer'></ins><ul id='1QVer'></ul><sub id='1QVer'></sub></form><legend id='1QVer'></legend><bdo id='1QVer'><pre id='1QVer'><center id='1QVer'></center></pre></bdo></b><th id='1QVer'></th></span></q></dt></tr></i><div id='1QVer'><tfoot id='1QVer'></tfoot><dl id='1QVer'><fieldset id='1QVer'></fieldset></dl></div>

                    <bdo id='1QVer'></bdo><ul id='1QVer'></ul>
                  <tfoot id='1QVer'></tfoot>

                    <small id='1QVer'></small><noframes id='1QVer'>

                  1. <legend id='1QVer'><style id='1QVer'><dir id='1QVer'><q id='1QVer'></q></dir></style></legend>