I’m very new to Ignition and have very limited experience with any kind of scripting. I’m working on a very simple report that has an XY plot on it that trends a temperature over a measured length. I’m able to query the temperature and length data, but I’m not sure how to incorporate my StartDate and EndDate parameters into the query so it pulls the data I’m looking for.
This is the code I have so far:
SELECT R105_GelStar_Trend.GelStar_ActTemp,
R105_GelStar_Trend.GelStar_Location
FROM R105_GelStar_Trend
When I test the query in the database query browser, it pulls data from a random date a few years ago. Any help would be appreciated.
That depends on what other columns you have and what data type they are. Do you have a column that contains a SQL date, or maybe a UTC time stamp column?
Hm, now I’m getting a “query could not be executed” message on the query browser. I’ve already watched that video a few times, and have looked in the online user manual. Neither were very helpful to me.
Looks like the JDBC connector used is Microsoft SQLServer.
When I was saying Universal, I meant this:
It looks like that code worked!
Which now brings me to me next issue… I only need the last 2 minutes of data. Also, the data don’t seem to be plotted on my XY chart in the report module when I add the data sources to the chart.
I should probably add, the reason I’m asking so many questions is that my company really doesn’t have an Ignition expert. So this is my main resource for any issues I’m running into.
That Universal is the syntax you’re telling query builder but it does not necessarily reflect what your actual db connection is. Go to your gateway->status->database connections and you should be able to tell there.
Run it in the query browser first to ensure you have data returned for the last 2 minutes, remember the query/report can’t give data that isn’t in the DB!
I don't think you have your keys configured correctly.
There are IU videos covering this.
I should probably add, the reason I’m asking so many questions is that my company really doesn’t have an Ignition expert. So this is my main resource for any issues I’m running into.
We're here to help, but consider going through IU also.
I've watched the IU video and it helped me figure out the data key issue.
My SQL query is as follows:
SELECT R107_GelStar_Trend.GelStar_ActTemp,
R107_GelStar_Trend.GelStar_Location,
R107_GelStar_Trend.t_stamp
FROM R107_GelStar_Trend
WHERE R107_GelStar_Trend.t_stamp BETWEEN ? AND ?
Where ? are my start date and end date parameters.
I'm confused why I'm not seeing any data plotted on the preview of my XY chart though. It seems like the preview is only using 100 points of raw data when there's far more than that in reality based on my query.