How retrieve data from a table using runNamedQuery

That is a dangerous place to run database operations. See this and its linked discussions:

If you must, you will need to change the call syntax to include the NQ project name to comply with that function's gateway scope requirement.