# Jython Logic Not Working?

**URL:** <https://forum.inductiveautomation.com/t/jython-logic-not-working/21496>\
**Category:** Ignition\
**Created:** [December 19, 2018, 2:12pm UTC](https://forum.inductiveautomation.com/t/jython-logic-not-working/21496 "2018-12-19T14:12:45Z")\
**Posts on this page:** 2\
**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:** [December 19, 2018, 2:12pm UTC](https://forum.inductiveautomation.com/t/jython-logic-not-working/21496/1 "2018-12-19T14:12:46Z")

</div>

I’m inserting rows into a db table with a button, but first I run a NamedQuery that returns a list of current values in the db table. If the new insert matches one currently in the db, instead of inserting new rows, it updates the current row’s qty.  
So the shortened code I’m using is this:

```auto
query = system.db.runNamedQuery('DuplicateChecker', vars)

duplicates = system.dataset.toPyDataSet(query)

style = row['STYLE'] + ' ' + size + material

if style not in duplicates:
       print 'Style is not currently in the database'

```

I put in some debugging code and verified that the duplicates datset is equal to  
`[0021910KP 5x5RB, 0F94-22KP 5x5RB]`  
and the style to check by is equal to  
`0021910KP 5x5RB`  
this obviously is in the dataset, so why does it print  
`Style is not currently in the database`

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 19, 2018, 2:30pm UTC](https://forum.inductiveautomation.com/t/jython-logic-not-working/21496/2 "2018-12-19T14:30:41Z")

</div>

Off hand I’d say it’s a type issue. _duplicates_ should end up being a list.

```python
query = system.db.runNamedQuery('DuplicateChecker', vars)

duplicates = system.dataset.toPyDataSet(query)

dupeList=duplicates.underlyingDataset.getColumnAsList(0)

style = row['STYLE'] + ' ' + size + material

if style not in dupeList:
       print 'Style is not currently in the database'

```

The zero in getColumnAsList is just the index number of the column. You should also be able to use column names.
