Hi!
I'm trying to insert data into SQL with an event (on mouse click) that runs a simple script:
def runAction(self, event):
ValorDataHora = system.date.now()
ValorArea = self.getSibling("CoordinateContainer").custom.Area
ValorMatricula = self.getSibling("CoordinateContainer").custom.Matricula
ValorPrioridade = self.getSibling("CoordinateContainer").custom.Prioridade
ValorEtiqueta = self.getSibling("CoordinateContainer").custom.Etiqueta
ValorSAP = self.getSibling("CoordinateContainer").custom.SAP
ValorTipoProblema = self.getSibling("CoordinateContainer").custom.TipoProblema
ValorOutros = self.getSibling("CoordinateContainer").custom.Outros
ValorDescricao = self.getSibling("CoordinateContainer").custom.DescProblema
ValorSolucao = self.getSibling("CoordinateContainer").custom.DesSolucao
ValorPeriodo = self.getSibling("CoordinateContainer").custom.PeridoRealizacao
ValorDataHora1 = str(ValorDataHora)
ValorArea1 = str(ValorArea)
ValorMatricula1 = str(ValorMatricula)
ValorPrioridade1 = str(ValorPrioridade)
ValorEtiqueta1 = str (ValorEtiqueta)
ValorSAP1 = str (ValorSAP)
ValorTipoProblema1 = str (ValorTipoProblema)
ValorOutros1 = str (ValorOutros)
ValorDescricao1 = str (ValorDescricao)
ValorSolucao1 = str (ValorSolucao)
ValorPeriodo1 = str (ValorPeriodo)
query = "INSERT INTO survey ( datahora, area, matricula, prioridade, etiqueta, sap, tipoproblema, outros, descricao, solucao, periodorealizacao) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
System.db.runPrepUpdate(query,[ValorDataHora1,ValorArea1,ValorMatricula1,ValorPrioridade1,ValorEtiqueta1,ValorSAP1,ValorTipoProblema1,ValorOutros1,ValorDescricao1,ValorSolucao1,ValorPeriodo1],"SQL")
But when i press the button with this event i get the following error:
Error running action 'dom.onClick' on LandingPageView/6_Resumo@D/root/Button: Traceback (most recent call last): File "function:runAction", line 30, in runAction NameError: global name 'System' is not defined
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File "function:runAction", line 30, in runAction
NameError: global name 'System' is not defined
caused by org.python.core.PyException
Traceback (most recent call last):
File "function:runAction", line 30, in runAction
NameError: global name 'System' is not defined
Ignition v8.1.42 (b2024061810)
Java: Azul Systems, Inc. 17.0.11
i was looking on Add Data to Database Video at Inductive University
Where the same System.db.runPrepUpdate was used but I'm still stuck with this error.
If anyone has any ideas or solutions for this case, i would appreciate!