cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging an Event

Baron
Participant
1,707

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

Accepted Solutions (0)

Answers (2)

Answers (2)

VolkerBarth
Contributor

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,

  • I can debug events when using SQL Central 16.0.0.2798 running on a local 16.0.0.2798 database server, and
  • I cannot debug events when using SQL Central 17.0.10.6057 running on a local 17.0.10.6057 database server. (However, I can debug stored procedures there.)
fvestjens
Participant

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

VolkerBarth
Contributor
0 Kudos

Well, before answering, I had just tested to debug a running event on a production database, and that surely worked as expected.

Baron
Participant
0 Kudos

nice, but how can I "make sure the debugger is set to debug all users or the one user running the event"

VolkerBarth
Contributor

The debugger prompts for "Which User Would You Like To Debug?" everytime you enter debug mode.

Baron
Participant
0 Kudos

Yes, it asks, and I leave the default answer as '*', but it still doesnt catch the breakpoint.

VolkerBarth
Contributor

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.

Baron
Participant
0 Kudos

I use 17.0.9.4803

fvestjens
Participant

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

fvestjens
Participant

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.

Baron
Participant
0 Kudos

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!