Something like the following works reasonably well in xemacs (probably it also works in regular emacs):
(defun dcw-find-query ()
"run grep on selection
Uses x-get-selection to get the grep string"
(interactive "")
(let* ((file-name
(concat (substring (buffer-file-name) 0
(string-match ".tcl$"
(buffer-file-name))) "*.xql")))
(grep (concat "grep -n "" (x-get-selection) "" " file-name))))
Then bind this function to a function key. To use just highlight the query name in the .tcl file and hit the function key.