Set QueryResultsObject to results of query within .odb file

In StarBasic, I know how to

QueryResultsObject = SQLStatementObject.executeQuery(SQLQueryString)

but is there a way to instead set the QueryResultsObject to the results of a query saved in the .odb file?

Addendum: I want to have the macro use certain values from the query, just as I would with a queryresult. I just don’t want the SQL hard-coded into the macro. I want it to depend on what is set up in the query saved in the .odb file.

Hello,
Sorry but do not understand:

Since QueryResultsObject is the result set, what is it you want to do with it? Example of what is wanted may be of help.

Sorry. I should have included that. I have added that to my question.

Hello,

Getting access in macro to saved Queries is fairly simple:
Rem Get access to Queries

    oDatabaseFile = ThisComponent.Parent.CurrentController.DataSource
    oQuery = oDatabaseFile.getQueryDefinitions()
Rem Get access to the query needed
    stQuery = oQuery.getByName("YOUR_QUERY")

You can also check for existence:

If NOT oQuery.hasbyname("YOUR_QUERY") Then

or create one:

    oQueryDefinition = createUnoService("com.sun.star.sdb.QueryDefinition")
    oQueryDefinition.Command = sSQL
    oQuery.insertByName("NEW_QUERY", oQueryDefinition)

and more.

Edit: The SQL is in stQuery.Command

Great, thanks!