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

What is oracle stored procedure?

coldplay.xixi
coldplay.xixiOriginal
2020-07-16 16:17:044320browse

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;

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;

As shown below

What is oracle stored procedure?

##5. Test the stored procedure just written

exec sp_demo('男');

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!

Statement:
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