[bug: IGN-2494] runSFNamedQuery Error:GatewayNamedQueryManager

As the Ignition documentation indicates, i want to use the ‘system.db.runSFNamedQuery’ function in a Gateway script to do an insert to 2 differents databases.
This function doesn’t succeed when ‘database’/‘datasource’ is a define as a parameter of namedquery

INFO | jvm 1 | 2021/06/14 15:58:34 | I [G.GTC_Lapi ] [13:58:33]: Fct: ‘shared.commun.lapi.manager.insertDBVehicule’ Message: ‘results[0] id:[1623679113] project:[TMB_GTC_AIRE_PASSY] , params:[{‘idtmd’: 1623679113L, ‘dateend’: Mon Jun 14 15:58:33 CEST 2021, ‘idhg’: 1623679113L, ‘datestart’: Mon Jun 14 15:58:33 CEST 2021, ‘numvoie’: 2, ‘database’: ‘histo_lapi’, ‘id’: 1623679113L, ‘idlog’: 1623679113L, ‘numzone’: 1}], pathQuery:[lapi/insertVehicule]’ store-forward-name={}, byes-script=GTC_Lapi
INFO | jvm 1 | 2021/06/14 15:58:34 | E [GatewayNamedQueryManager ] [13:58:33]: Could not store history for datasource ‘{}’ for query INSERT INTO hg(
INFO | jvm 1 | 2021/06/14 15:58:34 | id,
INFO | jvm 1 | 2021/06/14 15:58:34 | class,
INFO | jvm 1 | 2021/06/14 15:58:34 | width,
INFO | jvm 1 | 2021/06/14 15:58:34 | height)VALUES(
INFO | jvm 1 | 2021/06/14 15:58:34 | :id,
INFO | jvm 1 | 2021/06/14 15:58:34 | :class ,
INFO | jvm 1 | 2021/06/14 15:58:34 | :width,
INFO | jvm 1 | 2021/06/14 15:58:34 | :height )
INFO | jvm 1 | 2021/06/14 15:58:34 | . store-forward-name={}
INFO | jvm 1 | 2021/06/14 15:58:34 | java.lang.IllegalArgumentException: Specified historical sink ‘{}’ does not exist.
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.history.HistoryManagerImpl.storeHistory(HistoryManagerImpl.java:207)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.db.namedquery.GatewayNamedQueryManager.executeSFquery(GatewayNamedQueryManager.java:179)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runSFNamedQuery(GatewayDBUtilities.java:422)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/java.lang.reflect.Method.invoke(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:188)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:538)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyObject.call(PyObject.java:413)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.pycode.pyx341.insertDBVehicule$12(module:shared.commun.lapi.manager:463)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.pycode.pyx341.call_function(module:shared.commun.lapi.manager)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyTableCode.call(PyTableCode.java:171)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyBaseCode.call(PyBaseCode.java:308)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyFunction.function___call
(PyFunction.java:471)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyFunction.call(PyFunction.java:466)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.pycode._pyx341.tests$13(module:shared.commun.lapi.manager:492)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.pycode._pyx341.call_function(module:shared.commun.lapi.manager)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyTableCode.call(PyTableCode.java:171)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyBaseCode.call(PyBaseCode.java:125)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyFunction.call(PyFunction.java:403)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.pycode.pyx363.valueChanged$1(tagevent:valueChanged:6)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.pycode.pyx363.call_function(tagevent:valueChanged)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyTableCode.call(PyTableCode.java:171)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyBaseCode.call(PyBaseCode.java:308)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyFunction.function___call
(PyFunction.java:471)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyFunction.call(PyFunction.java:466)
INFO | jvm 1 | 2021/06/14 15:58:34 | at org.python.core.PyFunction.call(PyFunction.java:461)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:836)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:820)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:687)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$FunctionInvokerImpl.run(TagScriptManagerImpl.java:530)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.tags.scripting.events.AbstractTagScript.invoke(AbstractTagScript.java:34)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$Task.invoke(TagScriptManagerImpl.java:479)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$TagScriptDispatcher.run(TagScriptManagerImpl.java:442)
INFO | jvm 1 | 2021/06/14 15:58:34 | at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:538)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
INFO | jvm 1 | 2021/06/14 15:58:34 | at java.base/java.lang.Thread.run(Unknown Source)

Blockquote

def insertDBVehicule(id=None,dictParams={},datasources=[],project = ""):
	"""Fonction d'insertion en base de données via le SF d'un vehicule"""
	
	global INSERT_VEHICULE_QUERIES,DATASOURCES,LIB
	
	FCT = "insertDBVehicule"
	
	if id == None:
		#PK des enregistrements
		dtNow = system.date.now()
		msNow = system.date.toMillis(dtNow)/1000
		
	if project == "":
		import shared.commun.constantes
		project = shared.commun.constantes.getProject()
	
	if datasources == []:
		datasources = DATASOURCES.values()
		
	shared.commun.logger.logINFO(strMsg="Parameters id:[%d] project:[%s] datasources:[%s] dictParams:[%s]"%(id,project,str(datasources),str(dictParams)),strFct=FCT,strLib=LIB,dicoTrace={},strLog="GTC_Lapi")
		
	for type,params in dictParams.items():
		for datasource in datasources:
			#DANS chaque DS
			params['database']=datasource
			#params['datasource']=datasource
			
			params['id'] = id #Cle primaire de tous les enregistrements
			try:
				#result = system.db.runNamedQuery(project=project,path=INSERT_VEHICULE_QUERIES[type],parameters=params)
				result = system.db.runSFNamedQuery(project=project,path=INSERT_VEHICULE_QUERIES[type],params=params)
			except:
				shared.commun.logger.logERROR(strMsg="ERROR",strFct=FCT,strLib=LIB,dicoTrace={},strLog="GTC_Lapi")
			shared.commun.logger.logINFO(strMsg="results[%d] id:[%d] project:[%s] , params:[%s], pathQuery:[%s]"%(result,id,project,params,INSERT_VEHICULE_QUERIES[type]),strFct=FCT,strLib=LIB,dicoTrace={},strLog="GTC_Lapi")
				

This has been fixed in 8.1.8 and is available now in the nightlies.