From the course: Scala Essential Training for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Querying with prepared statements

Querying with prepared statements - Scala Tutorial

From the course: Scala Essential Training for Data Science

Start my 1-month free trial

Querying with prepared statements

- [Instructor] Now let's take a look at working with prepared statements. A prepared statement allows us to execute a query repeatedly without forcing the database to parse and build a query execution plan each time we execute that statement. So prepared statements are especially useful when we're using O Statement repeatedly. So the first thing I want to do is to find a query string. And I'll just type in val, query, STR. And I'll say that this statement is select star, from company, regions where region ID is greater than some number. And I want to put in, essentially a parameter here. So I'll be able to change it. So we'll use a question mark for that. Now, what I will do is actually to create, using that query string, a prepared statement. And I'll just use PS for the name of the value for that. And to do that we specify our connection, and use the prepare statement method. And we pass in our query string. Okay so now we have a prepared statement. And that means the database has…

Contents