You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing firstname.lastname@example.org.
We are experiencing playback issues from our video hosting provider. Please check back shortly.
4:55Indirect Tag Binding
5:35Tag History Binding
Take topic challenge
Query bindings allow Perspective components to call Named Queries, providing easy access to a database.
Video recorded using: Ignition 8.0
Transcript(open in window)
[00:00] In this lesson, we'll take a look at Query Bindings in the Perspective Module. We can see that I have a Table component here and I would like to place a Named Query Binding on this component. So we know the data property here on the Table allows us to populate the Table with data. So we'll hit the binding icon here. We'll select the query type, and then we need to select a Named Query. Now that Query Binding type, in Perspective, only uses Named Queries. You can't type a query here from this interface. Instead you have to go and create a Named Query. For more information on that, take a look at some of the videos we have on Named Queries. If you have some created, you can click on the little icon over here and you'll see a list of all the available Named Queries in the project. For our first example, I'll select this one called, Simple Query, hit select. You can see a preview of it over here, it's simply returning the string, Hello IU. Now, if I hit OK here, you can see on my Table, it's showing me the results. Now, if I go back to my binding here, we can see that the return format is set to auto. So depending on how you've configured your Named Query, this could return a dataset, or it could return a scalar value. This drop-down here allows you to override and modify the format. So my Named Query is just a standard query type which means it's returning a dataset. Now that's try this same Named Query, but on a different component. So I won't use the Table this time, we'll use a Label. I head over to the Component Palette, go to the Display category, and I can grab a Label Component, drag that onto my View somewhere. And let's try that again. So for this component here, we'll find the text property, we'll click the binding icon. Again, we'll click the query type. I'll go ahead and I'll browse, and I'll grab that simple query one more time here. Now, again, it's trying to bring back a dataset. So if I hit apply and move this out of the way here, it's not really super useful how it's being presented, so what we could do instead, is change the return format to scalar. Scalar will return the value that's in the first row and the first column. If I switch this to scalar, it will automatically pull the value out of the dataset, so my query's only returning a single value, so it really makes sense for my return format, in this case, be set to scalar. I'll press OK and you can see our Label is showing the results of the query in a more user friendly format. Now, I want to do something a little bit more interesting, I want to use some parameters with the Named Queries here on my Table. So, first of all, I'm going to come back to the Component Palette here. And under the Input category, let's go ahead and we'll grab a Text Field component. We'll drag that onto my View somewhere. For this next example, I want to type a number into the Text Field and then have a Named Query on the Table, use the value I typed as a parameter. So we'll select the Table. We'll go back to the binding on the data property. Let's change this Named Query, here. I do have an Equipment query we can take a look at, which does actually use a parameter and we see it defined up above here. So I could just type in a value, so I could just type in the number 1 here and hit enter, or we could hit the little functions or fbutton here. And then type in an Expression. So in this case here, how about we reference the text property under the props category on my Text Field. So, we'll grab a little property reference here. We'll go down and we'll find our Text Field component. We'll expand that. We'll go to the props category of properties. We'll grab the text property and hit OK. We'll hit OK one more time. I'll press enter, and you can see that it commits the value in the field there, so now we're set. We'll press OK on the binding window here. And you can see my Table has an empty dataset because I haven't typed anything into the Text Field. Let's go into preview mode, I'll type something in, and we can see the results up above. If I type in a different number, I get a different set of results. Now the last thing you might want to be aware of with these bindings here is that, by default, they don't poll. So these bindings are turned off by default. They only fire when the View opens. So what you could do is you could turn on polling down below then type in the number of seconds you want this binding to poll at. So hopefully you have a good idea how these Query Bindings work in Perspective. Again, I made a lot of assumptions with Named Queries so if you haven't learned about those yet, take a look at some of the Named Query videos.