Finding a query in projects

Hello,

I have about 14 perspective projects (Identical GUI with different station no.s). I have the following query (Trace log screenshot) running every few seconds from different projects, but I am not able to find it even with project search through Designer Launcher.

The yellow highlighted shows the project-name but the view under is from a different project altogether (same discrepancy for other instances of this query log) and it adds ‘@C’ at the end too as shown. Is there a better way to track it down? Thanks

I am not able to find it even with project search through Designer Launcher.

I don't think you can search from Launcher. Did you mean Designer itself?

I have about 14 perspective projects (Identical GUI with different station no.s).

Why? Why not one project with parameters?

4 Likes

In the search tool did you make sure to check all the boxes to search all views, events etc? It does not do it by default.

Also I agree with @Transistor something about this setup smells.

I inherited this whole thing recently. No plans to change as it will go away after a few months

I mean I searched through ‘Designer’ after opening the project. Everything was checked when I did the ‘Ctrl+F‘.

You can open the projects folder (Ignition\data\projects) in the Ignition installation directory with an application like Notepad++ or VSCode and search the folder for that string. You should find it in a query.sql file if it is a Named Query, a *.py file if it is built directly into a project library, or in a view.json file if it’s in a component action or a binding.

Update 1: *low chance it’s in an external python library which would be not located in the projects folder but in the path: \Ignition\user-lib\pylib so you might need to search there too.

2 Likes

Still can’t find it. So weird

just search from parts or where pallet. Who knows why it’s not popping up if you paste the full string, extra space or line break could be to blame.

3 Likes

Good thinking. I'd search for "where pallet" first, because I always put the WHERE on the start of a new line.

2 Likes

That was a test if you practice good SQL query writing, and you passed :wink:

1 Like

Not exactly the same issue unless all your projects inherit from one parent project, but it reminded me of a feature request I made:

1 Like

I would even just search parts or pallet, no idea what kind of sql injection someone is doing “SELECT * FROM {} WHERE {} = ?”

1 Like

I have good faith they are using prepared statements w/system.db.runPrepQuery :slight_smile:

1 Like

Ah but we already know they inhereited this project and it’s architecture is questionable at best. Assume the worst hope for the best lol.

2 Likes

That suggests that the view is in a project that the project-name inherits from...? Does Sta_32_22_Interface have a parent project?

2 Likes

They don’t have a parent project. They had a base project and got imported and then saved after required changes/updates were done per station.

Yikes. I wish you luck with that! Lucky for you they are planned to no longer be used.

1 Like

I shutdown all perspective sessions and started to open one by one and finally was able to figure which projects are running the query.

I open one of the projects and can’t find the query again lol…

Gateway scripts? Project Scripts? Tag change scripts? SFCs? Transaction Groups?

I would run a tag report tool and select Query as the tag type to rule out tags.

5 Likes

Finally found the query object. So, the actual named query does not have TOP 1 in the query. I disabled the query on the object to make sure it’s not showing up in logs, verified it and re-enabled it.

Not sure why it’s being changed to ‘SELECT TOP 1 count(serial)’ from ‘Select count(serial)’ when the query is being executed.

Please throw some light if this behavior was observed before. Thanks.

Is the query returning a scalar1 value? This might cause the addition of the TOP 1 by Ignition's SQL engine.

1 The term "scalar" comes from linear algebra, where it is used to differentiate a single number from a vector or matrix. The meaning in computing is similar. It distinguishes a single value like an integer or float from a data structure like an array. Source: StackExchange.

2 Likes