Named query not working on label. PLZ help

I have a transaction group that counts the instances where a boolean tag is true.
I use a named query

SELECT count(count1_ndx)
FROM count1
WHERE t_stamp > 1639054080257

to return the number of instances from a particular time stamp

when I want to show it in binded in a label text it gives me an error of null


Apparently is of none type… what can I do?

I remember using named queries like this one in a table and obtaining the result, now even if I use a table I get the same error of null

The query is returning Null, which I will admit is a little odd.

If you open the Named query and run the query from the Testing tab, do you get the results you expect?

And in the case you get the same thing in the Testing tab, what do you get if you run this query directly on your database? Just so we know the expected result.

2 Likes

I thought of that too, but the Query is also returning Null, but is configured to return a dataset. I would expect to see Dataset[0 rows x 1 cols]

Speaking of, the binding should probably be configured for Scalar

1 Like

Yea I just tested it, doing a return None or erasing it does lead to a null result, not a class.org.python.core.PyNone.

Agreed, it looks like it should be scalar, in which case I’m unsure what you would need a transform script for. But it does appear to be one configured no?

@Resistor can you show the code from inside your transform script?

When I test the named query I get the numeric result back.

I only used the script to see which type of data it was returning, without it returns null… regardless of the return format(auto, scalar, etc.)

So to summarize - we expect to see 18, when you just bind to the namedQuery directly you get a null, and when you add transform script this turns into a PyNone? Very odd indeed. I’m out of ideas then.

Note you can always call Ignition Support, they’re very helpful, can remote in and help you troubleshoot directly.

Basically… and when I added the transform I used the type() function to see what type of data it was exactly.

Thanks anyway. I didn’t want to call because I barely know how to use the software and thought they only help troubleshooting but you needed to know how everything works

Oh well if you’re returning type() in your transform then it I can see why you get the PyNone at least.

You will get the most out of this forum generally speaking if you can show your code as well - that’s the only way any of us can really help you troubleshoot.

However the larger issue of your named query returning 18 in your testing tab but null in your binding is odd. The last thing I would ask - can you show your Authoring tab? I want to confirm the query in your Authoring tab matches what is shown in the binding.

Maybe what is causing this is that your named query was edited but not saved, so the testing shows one result, but the binding is still using the old version. Is the name named query you’re looking at in italics in the in the designer? Like this
image

im not sure this is the best way to filter a t_stamp tho
might be mixing up second and milisecond based tstamps..

Of course
image

I just now changed the name to see if the space I had before could have caused the problem. But it’s the same as in the last image I showed

Ok so its been edited. Save your project and reload you view. See if this fixes your issue.

Edit: I was able to recreate your basic problem. I created a named query that was SELECT 2 and bound that to a label text. Then I edited the query without saving it (which leaves it in italics) to SELECT 3
image

But my label still is running the result of the old named query until I save it -
image

After saving:
image

So save your project and then recheck your binding please.

3 posts were split to a new topic: Transaction group date format

could you remove the last 3 numbers and run the query again?

But it was edited after it was returning null.

But yes, I think I hadn’t saved it and now it is working. Such a little thing gave me such a headache :sweat_smile:

Thanks

btw do you know how I could change the t_stamp format in the transaction group?

1 Like

Right, after you make edits to your named query for it to propagate your bindings you do have to save so that your NamedQuery does NOT appear in italics in the designer object tree. Glad that fixed it.

You might want to make a post for your separate time stamp problem however as to keep issues self contained to single threads to help people in the future who might search for the same problem.

2 Likes

and on the binding? ah nvm it got sovled xd

1 Like