# Problem with tag Value Events - Value Change

**URL:** <https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985>\
**Category:** Ignition\
**Tags:** perspective, ignition81, database\
**Created:** [July 17, 2022, 9:15am UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985 "2022-07-17T09:15:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alberto\_Fagni](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alberto\_Fagni](https://forum.inductiveautomation.com/u/Alberto_Fagni)\
**Post date:** [July 17, 2022, 9:15am UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/1 "2022-07-17T09:15:57Z")

</div>

Hi at all.

currently i try to perform this script in a tag value change events:

```auto
  params = {"gaiacode":"APTS503"}
  val = system.db.runNamedQuery("aqualog",params)

```

When i execute this code in a Script Console the execution finished without error. But inside value change events of every tag in my tag browse it sucks!

Have you got an idea to fix it?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 17, 2022, 9:19am UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/2 "2022-07-17T09:19:43Z")

</div>

> [@Alberto\_Fagni](#):
>
> But inside value change events of every tag in my tag browse it sucks!

"It sucks!" isn't an Ignition error code. What is the actual error message?

* * *

Tip: use the \</\> to format your code.

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [July 17, 2022, 9:26am UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/3 "2022-07-17T09:26:26Z")

</div>

I would check if the named query exists in the specified gateway scripting project, if specified at all.

[https://docs.inductiveautomation.com/display/DOC81/Project+Library#ProjectLibrary-GatewayScriptingProject](https://docs.inductiveautomation.com/display/DOC81/Project+Library#ProjectLibrary-GatewayScriptingProject)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 17, 2022, 1:07pm UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/4 "2022-07-17T13:07:55Z")

</div>

In gateway scope, you need three arguments to [runNamedQuery](https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery).

---

<div class="post-metadata">

**Author:** ![Alberto\_Fagni](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alberto\_Fagni](https://forum.inductiveautomation.com/u/Alberto_Fagni)\
**Post date:** [July 17, 2022, 3:00pm UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/5 "2022-07-17T15:00:56Z")

</div>

I have no errore message.  
I use a try-except statement and the only things that i see is that the code skip to except area

---

<div class="post-metadata">

**Author:** ![Alberto\_Fagni](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alberto\_Fagni](https://forum.inductiveautomation.com/u/Alberto_Fagni)\
**Post date:** [July 17, 2022, 3:02pm UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/6 "2022-07-17T15:02:13Z")

</div>

Now i try this:

```auto
debug = "[default]debugScript"
system.tag.writeBlocking([debug],["c"])
try:
	val = system.db.runQuery("SELECT 1") 
except:
	system.tag.writeBlocking([debug],["d"])

```

in my debug tag i see “d”

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 17, 2022, 3:44pm UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/7 "2022-07-17T15:44:50Z")

</div>

In gateway scope, the `database` connection name argument to [runQuery](https://docs.inductiveautomation.com/display/DOC81/system.db.runQuery) is required.

Your `except:` can inspect/print/log the actual exception information via python's `sys` and/or `traceback` modules, though you will need a separate `except:` clause to capture java errors. See this example:

> [@readBlocking and timeout exception](https://forum.inductiveautomation.com/t/readblocking-and-timeout-exception/38921/3):
>
> If the error was a direct throw of that TimeoutException, your except clause would work. But it is being wrapped in some other throwable (the TimeoutException add as the cause). I recommend this structure for this case: import java.lang.Throwable def someFunction(): try: system.tag.writeBlocking(.....) except java.lang.Throwable, t: # do something, including looking at t.cause except Exception, e: # do something with other python problems.

Note that any uncaught errors or logging or printing from gateway scope show up in the gateway log, not in the designer's console or client console. Printing, in particular, only goes to the text-format wrapper log.

{ Have you gone through the lessons in IA's [Inductive University](https://inductiveuniversity.com/courses/ignition-overview/8.1) ? That would cover many of the basic concepts of Ignition and Python that are tripping you up. }

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 17, 2022, 5:31pm UTC](https://forum.inductiveautomation.com/t/problem-with-tag-value-events-value-change/61985/8 "2022-07-17T17:31:16Z")

</div>

@Alberto_Fagni, please try this going forward:  
If you supply snippets on the forums, please either use the UI to format the code using the `</>` formatting tool, or place all of your code between triple backticks  
`````  
code here  
`````  
to allow for easier reading. I’ll edit your previous posts to assist in this thread, even though you’ve already been directed to the solution to your problems.  
 ![Screen Shot 2022-07-17 at 10.30.31 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/d/3de73a8dd2848c8780d1167f47f77de669d7b2dc.png)
