The query dispatcher makes some assumptions about how procs using the db api are called, and you've apparently broken one of them. This is a bit fragile, unfortunately. You may need to do the same thing that www/index.tcl does: specify the fully qualified query name rather than the relative query name.