What is a stored procedure in SQL?
In SQL, stored procedure is a set of statement (s) that perform some defined actions. We make stored procedures so that we can reuse statements that are used frequently. Stored procedures are similar to functions in programming. They can accept parameters, and perform operations when we call them.
What are the different types of DB2 stored procedures?
Known to DB2 via CREATE PROCEDURE statement •2 types: SQL (written in SQL/PL) External (RPG, CL, any language) We will focus on SQL stored procedures •Can be called from any environment that supports SQL •Can have parameters for input / output •Can return result sets •Can be selected from the database repository
Is it possible to use stored procedures for more than select statements?
Many people wrote asking if it was possible, and if so how to do it, to use stored procedures do to more than select statements. Absolutely!!! Anything that you can accomplish in a sql statement can be accomplished in a stored procedure, simply because a stored procedure can execute sql statements. Let's look at a simple INSERT example.
How many parameters can a stored procedure have?
First off, the parameter: you can have as many parameters as you want, or none at all. Parameters are set when the stored procedure is called, and the stored procedure receives it into a variable. @myInput is a variable. All variables in a stored procedure have a @ symbol preceding it. A name preceded with @@ are global variables.