Named Query - SQL temporary tables

I have a Named Query that uses a global MS SQL temporary table (##temptablename)

This query runs without error in the client as part of the running project.
This query runs without error in the designer in the Testing tab of the named query.

I am attempting to run this named query in the script block of an alarm pipeline. I make the call as follows in the format discussed in the documentation for gateway scope:

dbTableName = “[default]Historian/Deviation Alarm Info/DeviationOrigin” (tag path to the parameter needed for the named query)
params = {“param1”:dbTableName}
deviationMakeupValuesDataset = system.db.runNamedQuery(“MyProject”,“namedQueryName”, params)

when an alarm is triggered, the statement produces this error in the wrapper.log

INFO | jvm 1 | 2018/12/12 14:18:28 | java.lang.Exception: java.lang.Exception: Invalid object name ‘##temptablename’.

Is there some type of issue when temp tables are used in named queries that are being run in the gateway scope?

I don’t know of a problem. No matter where your named query originates, it always executes on the gateway. The client and gateway should be using exactly the same saved version of the named query. (The designer uses a local version – otherwise you’d never be able to test changes to a named query without saving and potentially messing up other things).