The syntax structure of the stored procedure :
Create or replace procedure过程名as(param1 in type,param2 out type)
variable1 type (value range ) ;
variable 2 type (value range) ;
declaration statement segment;
begin
---- execute the statement segment;
If ( judgment condition )
……
End if;
Exception
---- Exception handling statement segment;
When others then
Rollback;
End;
A procedure is a named block, the as keyword replaces the declare of an unnamed block
Precautions:
1 , the stored procedure parameter does not have a value range, in means incoming, out means output
2 , the variable has a value range, followed by a semicolon
3. Before judging the statement, it is best to use the count ( * ) function to judge whether the operation record exists
4. Use select...into... to assign values to variables
5 , throw an exception in the code with raise+ exception name
6, Create or replace procedure If there is no such stored procedure in the system, create a new one. If there is such a stored procedure in the system, delete the original one and re-create a stored procedure.