Calling The Query From Another Command

Sounds like this can be accomplished through a Custom API Quote System. See if this following thread can accomplish what your trying to do.