# Table Query Fail

**URL:** <https://forum.inductiveautomation.com/t/table-query-fail/18406>\
**Category:** Ignition\
**Created:** [June 11, 2018, 7:13pm UTC](https://forum.inductiveautomation.com/t/table-query-fail/18406 "2018-06-11T19:13:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 11, 2018, 7:13pm UTC](https://forum.inductiveautomation.com/t/table-query-fail/18406/1 "2018-06-11T19:13:25Z")

</div>

I have a table running a simple query.

```auto
SELECT*FROM alarms_r1
where date between time and time
```

I noticed while working that the table was encountering an error as shown below.

> On: Alarms.Root Container.Table.data  
> caused by GatewayException: Unable to read response from Gateway.  
> caused by org.xml.sax.SAXParseException; lineNumber: 31; columnNumber: 43; An invalid XML character (Unicode: 0x1) was found in the element content of the document.

I narrowed it down to 2 db entries that were causing the error.  
The entries are of type string, and they contained "PS79 PROGRAM NOT MATCH" and "BG79 PROGRAM NOT MATCH"  
When I edited the db and put a space in to make the entries "PS 79 PROGRAM NOT MATCH" and "BG 79 PROGRAM NOT MATCH" the error stopped? What is up with that??

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [June 11, 2018, 7:23pm UTC](https://forum.inductiveautomation.com/t/table-query-fail/18406/2 "2018-06-11T19:23:36Z")

</div>

According to the error, you had a special Unicode control character in your result: [0x1 - SOH](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#SOH)

How was the data entered? Even if it’s a string directly from a PLC you might still need to sanitize it by at least stripping out control codes.

---

<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:** [June 11, 2018, 7:26pm UTC](https://forum.inductiveautomation.com/t/table-query-fail/18406/3 "2018-06-11T19:26:00Z")

</div>

It also means that Ignition’s serialization/deserialization of the result dataset via XML failed to accommodate a legal character in a string. Sounds like a bug to me.

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [June 11, 2018, 7:34pm UTC](https://forum.inductiveautomation.com/t/table-query-fail/18406/4 "2018-06-11T19:34:20Z")

</div>

If the data comes from Ignition first, you can use Python’s strip function to remove any nasty Unicode characters before storing it:

```auto
sanitized = original.strip(' \f\t\r\n\00') # strip out control characters

```

I encountered this same issue reading strings from Mitsubishi Q-Series PLCs.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 11, 2018, 7:37pm UTC](https://forum.inductiveautomation.com/t/table-query-fail/18406/5 "2018-06-11T19:37:22Z")

</div>

The string is being logged by a transaction group from an OPC tag originating from a Fanuc OPC server. The error codes come from a Fanuc CNC controller. The error codes are verbatim to the error code/message displayed on the controller itself.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 11, 2018, 7:58pm UTC](https://forum.inductiveautomation.com/t/table-query-fail/18406/6 "2018-06-11T19:58:32Z")

</div>

> [@bfuson](#):
>
> If the data comes from Ignition first, you can use Python's strip function to remove any nasty Unicode characters before storing it:

What confuses me is I have logged other error codes like "PS125 MACRO STATEMENT FORMAT ERROR" with no issues  
the PS125 being the same format as the PS79 that caused an error.
