[00:00]
In this lesson, we'll create a basic SQL query data source. This data source is the common type typically seen through much of Ignition before version 7.8. It might look similar to a query binding you would see on a vision component. To start, on the report Data tab, we click on the plus icon and click on basic SQL query. When we create this data source, you can see a placeholder query here. Moving over to the right side of the screen, we can take a look at some of the properties here. The Data Key is also the name of the data source. I'm going to change this to Fruit Report. We can also select the Query Type from the drop down here. One thing to note is if you change the Query Type, your query will be wiped out. Make sure to create a copy if you're going to change the Query Type. We can also specify the Database and modify the Preview Limit. We'll come back to the Preview Limit a little later.
[01:05]
Finally, there's an area where you can build out Nested Queries. Let's take a look at the data that I want to bring in. I'll head over to the Database Query Browser. And you can see that I have 10 rows of data within this table here that holds information about customers orders of fruit. I want to pull in each of these rows into my report. I'll close out of the Query Browser and head back over to my report and paste my query here. I'll go to the Preview tab and as you can see all of the rows of data are being pulled into my report. If I go back to the Data tab, we can take a look at that preview limit again. This property limits the number of rows returned by your data sources when in the preview mode. Change this to 5, and if I head back to the Preview, you can see that there are only five rows now. This can be useful when you want to look at the raw data or perform any troubleshooting.
[02:03]
Keep in mind that this limit will only be applied to the preview. Another thing that we can do is filter the results of this query based on a parameter. I'll create a New Parameter and call it 'Customer Name.' I'll give it a default value of Mary. But remember, this can be overridden. now in the query we can add another line with a where clause I'll click the parameter icon and Customer Name and you can see that it adds the parameter to the query. Now since this is a string it'll need quotes. Heading back to the preview, we can see that there are only rows for Mary's data now. Now, let's take a look at a Vision report viewer.
[03:03]
I'll head over to my window that I've already set up. It has a Report Viewer component and a drop-down list with each of the customers names. I have a binding on the customer name parameter that links it to the drop-down selection. And you can see that when I choose a different customer, a new report is generated with rows pertaining to that customer.