cancel
Showing results for 
Search instead for 
Did you mean: 

How can a SP get the call stack like its shown in SC Debugger

reimer_pods
Participant
2,431

In a stored procedure I'd like to get the call hierarchy like it's shown in the tab "Call Stack" when debugging with Sybase Central.

I remember having seen a system procedure or function for that, but I can't seem to find it. Can annyone point me to that procedure (or tell me my memory is wrong)?

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor

Are you looking for the following system function?

select traceback();
reimer_pods
Participant
0 Kudos

Thanks Volker, that's what I was looking for. But not remembering how it's called I couldn't find any trace of it 😉

reimer_pods
Participant
0 Kudos

Volker's answer helped me find the function I've seen before. But to my disappointment it's only result is the SQL command that was executed when an error occured.

What I had in mind, was getting informations about where the error occured (procedure or trigger). But I suppose that there exists not such function, or am I wrong?

VolkerBarth
Contributor
0 Kudos

Well, at least we can tell you your memory is not wrong:)

MarkCulp
Participant
0 Kudos

The next version (aka Nagano) has new-and-improved error reporting & traceback functions, so check out the beta if you haven't already.

reimer_pods
Participant
0 Kudos

Thanks, Mark, I will check the new features.

VolkerBarth
Contributor
0 Kudos

One workaround I have thought of (but don't know whether it would work at all, and it would require work...):

  • Add an execption handler in each relevant procedure (in case you've not done that)
  • Inside the handler, use TRACEBACK() to get the last local statement (in case it will really show that) and message that to the log or somewhere else.
  • Re-signal the error...

As stated, I don't know whether this will work, and of course the "re-signal" would possibly interfere with the attempt to handle errors locally...

reimer_pods
Participant
0 Kudos

Volker, thank you for the suggestion. The hard part is the "relevant procedure" as that is exactly what I'm wanting to find out. The database for that application has ~600 SP and ~400 triggers created over the last 15 years, many of them lacking proper error handling.

So my next step will be to try the-soon-to-be-released-version of SA (kind of "He-Who-Must-Not-Be-Named" ;-)).

VolkerBarth
Contributor
0 Kudos

TRACEFORWARD(), as they say:)

reimer_pods
Participant
0 Kudos

Well, I tried TRACEBACK () in Nagano beta, but to no avail, it does exactly the same as SA12, just shows the line executed when the exception was fired. So maybe the documentation is ahead of the beta release ...

MarkCulp
Participant
0 Kudos

Reimer: Note that the traceback() and error_*() functions only provide useful information if used within an exception (or catch) block. Once the stack has unwound the information is no longer available.

Answers (0)