As I understand it in a tcl library (-proc) file, the fully qualified name will be procedure name followed by query name i.e.
name="myproc.run_this_sql"
Whereas in a tcl/adp pair page, only the query name is required
Of course as you'll notice this does lead to quite a lot of duplication of identical queries based on context.
As for your problem, it sounds like a variable you've used in a query hasn't been set prior to calling the query in the script.
Usually, if your problem is query naming you'll get a
Querying: ''
in the log file, i.e. the dispatcher doesn't see the query at all.