on 2020 May 19 5:27 PM
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
The debugger prompts for "Which User Would You Like To Debug?" everytime you enter debug mode.
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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
9 | |
9 | |
8 | |
8 | |
7 | |
7 | |
6 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.