Oracle stored procedure is: first configure the database that needs to be connected; then open the [PL/SQL] database tool; then enter the stored procedure that needs to be created in the SQL input interface; and finally test the written stored procedure.
Oracle stored procedure is:
1. Configure the database that needs to be connected through the Net Manager that comes with ORACLE. For example, COST
2. Open the PL/SQL database tool, enter the correct user name, password and selection, click OK to enter the user who needs to create the stored procedure
3. Understand the format of general stored procedures
create or replace procedure 存储过程名(param1 in type,param2 out type) as 变量1 类型(值范围); 变量2 类型(值范围); Begin 语句块 Exception --异常处理 When others then Rollback; End;
4. Enter the stored procedure to be created in the SQL input interface,
create or replace procedure sp_demo(param1 in varchar2,param2 out varchar2) /* * 存储过程实例 */ as cnt int; rst varchar2(100) Begin Select count(*) into cst from Tab_Demo where Col_Value = param1; If (cst > 0) then --判断条件 param2 := '有匹配的值'; Else param2 := '无匹配的值'; End if; Exception When others then Rollback; End;
As shown below
##5. Test the stored procedure just writtenexec sp_demo('男');
Related Learning recommendation:
The above is the detailed content of What is oracle stored procedure?. For more information, please follow other related articles on the PHP Chinese website!