# Database failover update query

**URL:** <https://forum.inductiveautomation.com/t/database-failover-update-query/10889>\
**Category:** Ignition\
**Created:** [December 8, 2015, 2:55pm UTC](https://forum.inductiveautomation.com/t/database-failover-update-query/10889 "2015-12-08T14:55:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DWeber](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@DWeber](https://forum.inductiveautomation.com/u/DWeber)\
**Post date:** [December 8, 2015, 2:55pm UTC](https://forum.inductiveautomation.com/t/database-failover-update-query/10889/1 "2015-12-08T14:55:29Z")

</div>

I cant get this query to work. I’m not sure why it doesn’t recognize this tag value. I assume I wrote the tag read incorrectly.

if system.tag.read("[System]Gateway/Database/JMCProcess/Available")==0:  
qV1 = event.source.parent.getComponent(‘Popup Calendar’).date

```
system.db.runPrepUpdate("INSERT INTO PM_Fat_Ratio_XRay (time_stamp) VALUES (?)",[qV1], 'JMCProcess')

```

elif system.tag.read("[System]Gateway/Database/JMCProcess/Available")==1:  
qV1 = event.source.parent.getComponent(‘Popup Calendar’).date

```
system.db.runPrepUpdate("INSERT INTO PM_Fat_Ratio_XRay (time_stamp) VALUES (?)",[qV1], 'FATRATIO')

```

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/ee24cc8208583dcabaa141c429f86f25613b6a4e.PNG)

---

<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:** [December 8, 2015, 3:12pm UTC](https://forum.inductiveautomation.com/t/database-failover-update-query/10889/2 "2015-12-08T15:12:33Z")

</div>

[quote=“DWeber”]I cant get this query to work. I’m not sure why it doesn’t recognize this tag value. I assume I wrote the tag read incorrectly.[code]if system.tag.read("[System]Gateway/Database/JMCProcess/Available").value==0:  
qV1 = event.source.parent.getComponent(‘Popup Calendar’).date  
system.db.runPrepUpdate(“INSERT INTO PM\_Fat\_Ratio\_XRay (time\_stamp) VALUES (?)”,[qV1], ‘JMCProcess’)

elif system.tag.read("[System]Gateway/Database/JMCProcess/Available").value==1:  
qV1 = event.source.parent.getComponent(‘Popup Calendar’).date  
system.db.runPrepUpdate(“INSERT INTO PM\_Fat\_Ratio\_XRay (time\_stamp) VALUES (?)”,[qV1], ‘FATRATIO’)[/code][/quote]Yes, you left out the value references. I added them in the code above, along with [code] and [/code].  
[system.tag.read()](https://docs.inductiveautomation.com/display/DOC/system.tag.read) returns a Qualified Value object, which contains the requested tag value in it’s value property.
