Calling named query from scripting

Tip: format code as code using the </> button, not quotations using the button (or > prefix). For more see Wiki - how to post code on this forum.