Rock U - Lava - SQL Command

Transcribed Video Content

Okay. So let's look at the SQL command now. The SQL command is all the entity command but instead of using parameters to filter based on entities, you're basically providing a SQL statement. So this does require that something about SQL. So in this example, we just provide a simple SQL statement that's basically saying select nickname and last name from person where last name equals Decker. And what all this will do is it's gonna take the results of the SQL command and it's gonna stuff it into a variable called results. Then you'll iterate over that using the for statement for command and just spit out nickname and last name. So each one of your select parameters here, nickname and last name will then be available in the item dot nickname and item dot last name. So super simple way of taking a select statement and, putting the results out in Lava either onto a web page or maybe you're using it in some other place in a workflow. And that was the results. Now, sometimes you might have some data in your Lava template either passed into it or in this case we have assigned to it. Just note that you can actually embed that Lava into your SQL statement. So you basically have Lava with inside of Lava, which is really powerful. So what will happen is when we before we run this SQL statement, we will, parse this string here for Lava itself and it'll put in the value there. So in this case, the word Decker would be placed right where last name is and then we'll run it. Okay? Now in some cases, you may not wanna do a SQL statement. You might wanna do an update or if you're very, careful, a delete. And so in this case what we're doing is we're saying, hey, this statement I'm about to provide you is a command. Okay? You don't need to put statement if it's a select. We just assume it's a select statement. But if it's a update or delete, you need to say you need to tell us ahead of time and warn us that it's a command. And so what we'll do is we'll just go ahead and, run that command and what you'll get back is actually the number of rows that was modified. Okay. So then here we can say the results instead of being a whole list of things will be the number of rows that were modified. So in this case, it's three workflows were updated. So that's the SQL command. Look for more, tips and tricks on the Rocklava page.