Stored Procedures are generally a group of SQL statements that allows you to make a single call to a database. The SQL statements in a stored procedure are executed statically for better performance. A stored procedure contains input, output, or both the input and output parameters. A stored procedure returns a value through the OUT parameter after executing the SQL statements. A stored procedure can return multiple ResultSets.
Let's see an example to execute a stored procedure with IN parameters:
To call the stored procedure, you need to create it in the database. Here, we are assuming that stored procedure looks like this.
The table structure is given below:
In this example, we are going to call the stored procedure INSERTDEMO that receives id and name as the parameter and inserts it into the table user. Note that you need to create the user table as well to run this application.