cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

How can I obtain the object_id value for executing SQL Anywhere code. If accessible, I could then obtain the name of the executing SQL Anywhere code with:

declare my_object_id integer;
declare executing_object_name char (128);

set my_object_id = ???;
set executing_object_name = object_name (my_object_id);

If I knew what to substitute into '???', I could obtain the name of any stored procedure or trigger that is currently executing.

Is there another way to do this?

Thanks, Dan.

0 Likes
View Entire Topic
Former Member

There is a global variable available called @@procid (as part of the TSQL support) that may help.

Doing something along the lines of

 select proc_name from sys.sysprocedure where proc_id=@@procid;

seems to fix your purpose.

This was added back in version 5 and is still documented for V16 and still seems to work in V17. Future versions may or may not continue this tradition.

dhkom
Participant
0 Likes

Thanks. I was aware of the @@procid technique. I was hoping to find a similar technique to determine the id of an executing trigger (@@triggerid does not exist), or better yet, a single way to find the object_id of the executing SP or trigger.