--a preliminary understanding of Oracle--procedure,
--1.1 Create a complete procedure with the following format
Create or replace procedure Procedure_name
Is/as
Begin
Subject
exception
Exception Handling Body
End procedure;
Procedure_name is the process name
Or replace is used to overwrite the process of the same procedure name, if created, without or replace and you create a process name that just exists, will be an error
Parameter type: in
Input parameters, indicating that this parameter value can be entered into the process for use by the procedure, is the default type, cannot be modified.
Parameter type: Out
The output parameter, which indicates that the parameter is assigned in the process, can be provided to the part or environment that the process body thinks of.
Parameter type: in Out
Input and output parameters can either receive the actual parameter values, or can be modified by the program, you can output
For example:
Create or replace procedure Comunt_num
(In_sex in Teaches.sex%type)
As
Out_num number;
Begin
If in_sex= ' M ' then
Select COUNT (SEX) into Out_num from teachers where sex= ' M ';
Dbms_output.put_line (' Number of male teachers: ' | | out_num);
Else
Select count (Sex) into out_num from teachers where sex= ' F ';
Dbms_output.put_line (' Number of female teachers: ' | | out_number);
End If;
End Conut_num;
1.2 Call of the stored procedure:
Execute stored procedure name parameter;
1.3 Deletion of stored procedures:
drop procedure Stored Procedure name
Oracle----PROCEDURE