简体   繁体   English

如何在 Oracle SQL 开发者(版本 20.4.1.407)中调试触发器?

[英]How to debug a trigger in Oracle SQL developer (version 20.4.1.407)?

I have the following before-insert trigger, that assigns a sequence number to a record of an intersection table:我有以下插入前触发器,它将序列号分配给交集表的记录:

before insert on psln
for each row 
declare v_seqnr number;
begin
  select nvl(max(psln_seqnr),0) into v_seqnr from psln where pers_id = :new.pers_id;
  :new.psln_seqnr := v_seqnr + 1;
end;

Now i want to debug this trigger to see if v_seqnr gets the proper value, depending on the value of:new.pers_id.现在我想调试此触发器以查看 v_seqnr 是否获得正确的值,具体取决于:new.pers_id 的值。 These are the steps i take:这些是我采取的步骤:

  • i configure the Start Debugging Option (Tools - Preferences - Debugger) as follows:我配置启动调试选项(工具 - 首选项 - 调试器)如下:

首选项 - 调试器

(when i choose a different option, my stack window remains empty while debugging, see below) (当我选择不同的选项时,我的堆栈 window 在调试时保持为空,见下文)

  • i compile the trigger for debugging (Ctrl-Shift-F8)我编译触发器进行调试 (Ctrl-Shift-F8)
  • i place a breakpoint on the begin-statement我在开始语句上放置一个断点
  • i start debugging the trigger (Ctrl-Shift-F10) and get the following debug popup window, where i enter the values 1,1 for the insert-statement, that will cause the trigger to fire:我开始调试触发器 (Ctrl-Shift-F10) 并获得以下调试弹出窗口 window,我在其中为插入语句输入值 1,1,这将导致触发器触发:

调试弹窗

  • i press OK and see the following (note the green V on the red breakpoint, which i think is the point of execution):我按 OK 并看到以下内容(注意红色断点上的绿色 V,我认为这是执行点):

调试1

  • when i now click on the Step-Into debug-icon with the red arrow (or press F7), i expect to jump to the first line of code in the begin-block, but nothing happens...当我现在单击带有红色箭头的 Step-Into 调试图标(或按 F7)时,我希望跳转到开始块中的第一行代码,但没有任何反应......
  • i also expect to see the value 1, when holding my mouse over the:new.pers_id expression, but this also does not work当我将鼠标悬停在 new.pers_id 表达式上时,我也希望看到值 1,但这也不起作用

Can someone please explain me what i am doing wrong or what i have forgotten?有人可以向我解释我做错了什么或我忘记了什么吗?

I think this is a known bug, in SQLDEVELOPER, one fix for it, could be instead of use an ANNONIMOUS PROCEDURE (which is created when you type in the "lady bug"), you can try to fire the trigger by a normal STORE PROCEDURE, that means, you can create a "dummy", procedure which emulates the insert, compile it for debug, an run it, if all work well, your execution should stops in the trigger's break point, is like to do a simulation of debug a procedure which has a trigger in.我认为这是一个已知的错误,在 SQLDEVELOPER 中,一个修复程序可以代替使用 ANNONIMOUS PROCEDURE(当您输入“lady bug”时创建),您可以尝试通过普通 STORE 触发触发器PROCEDURE,这意味着,您可以创建一个模拟插入的“虚拟”过程,编译它进行调试,运行它,如果一切正常,您的执行应该在触发器的断点处停止,就像模拟调试一个有触发器的过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM