I have created an event with a handler of several lines. I need to debug those lines, so I connect the DB with Sybase Central, and set a breakpoint in the event, and I connect to the DB with DBISQL and trigger the event from DBISQL. I can see that the event is triggered but it never breaks on the set breakpoint! Is this because events make different own connection? How can I debug an event then? Thanks in advance |
You can certainly debug an event with the builtin debugger (*), and there is no need to move the code from the handler into a procedure to do so (although there may be other reasons to do that). You can even debug running events. But as events run on their own connection, you have to make sure the debugger is set to debug all users or the one user (aka the event owner) running the event. That being said, I personally do not debug events but use the MESSAGE ... TO LOG statement and logging tables to log whether an event does work as expected or fails somehow, and I generally use error handling code there because there's no GUI that would present you an error message... (*): Update: In my tests, it does not work as expected with v17.0.10, see comments below... Another update: I have once again checked within the same v16 database,
2
I just created a new event to test the debugging but I can't get it to work. CREATE EVENT "USR"."DebugThisEvent" HANDLER BEGIN declare l_variable integer=1; message 'Started: '|| current timestamp type info to console; CurrentLoop: loop if l_Variable = 10 then leave CurrentLoop end if; message l_Variable type info to console; set l_Variable = l_Variable+1; end loop END; I've set debugging for all users and set a breakpoint on the first message statement. Then in I-SQL I execute trigger event DebugThisEvent it runs successfully but the debugger is not stopping at the breakpoint
(20 May '20, 03:27)
Frank Vestjens
Replies hidden
Well, before answering, I had just tested to debug a running event on a production database, and that surely worked as expected.
(20 May '20, 03:30)
Volker Barth
nice, but how can I "make sure the debugger is set to debug all users or the one user running the event"
(20 May '20, 03:31)
Baron
Replies hidden
1
The debugger prompts for "Which User Would You Like To Debug?" everytime you enter debug mode.
(20 May '20, 03:40)
Volker Barth
Yes, it asks, and I leave the default answer as '*', but it still doesnt catch the breakpoint.
(20 May '20, 04:02)
Baron
1
What version do you use? - I checked with 17.0.10.6057, and I can reproduce the problem, as I cannot debug an event there, as well. For my answer, I had used an older version (16.0.0.2798, namely), and as stated, this works fine.
(20 May '20, 04:30)
Volker Barth
I use 17.0.9.4803
(20 May '20, 04:44)
Baron
1
I checked in 12.0.1.4436 and in 17.0.10.5866 and in both versions an event can not be debugged. So something along the way must have been changed
(20 May '20, 07:24)
Frank Vestjens
|
Move the code from the event into a stored procedure and call this procedure from within the event. That should do the trick. I also use message '' type info to console to send info to the console of the database. That way you can use the console to see what happens. Thanks, I am already doing this, but wanted to debug the real event how it works, having that I also pass parameters while triggering the event. And also wanted to know the reason, why I can't catch the breakpoints!
(20 May '20, 03:02)
Baron
|