Home > Database > Oracle > What is oracle stored procedure?

What is oracle stored procedure?

coldplay.xixi
Release: 2020-07-16 16:17:33
Original
4366 people have browsed it

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.

What is oracle 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

What is oracle stored procedure?

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

What is oracle 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;
Copy after login

What is oracle stored procedure?

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;
Copy after login

As shown below

What is oracle stored procedure?

##5. Test the stored procedure just written

exec sp_demo('男');
Copy after login

What is oracle stored procedure?

Related Learning recommendation:

oracle database learning tutorial

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template