You can also get access to the page that the proc is executing in by using info script command. So for a tcl page you can uniquely reference a query using the combination of the page name and the statement name. For tcl library procs, you could use the combination of the query statement name, and the tcl proc name to uniquely reference the query.