Oracle存储过程的创建

本人是Oracle 的热捧者,以下的相关内容主要是我个人对于Oracle存储过程的一个总结,其中包括储存过程的创建,以及变量赋值的实际应用,以下就是文章的具体内容的描述,希望你会有所收获。

1、创建存储过程

 

 
 
 
  1. create or replace procedure test
    (var_name_1 in type,var_name_2 out type) as  

声明变量(变量名 变量类型)

 

 
 
 
  1. begin  

Oracle存储过程的执行体

 

 
 
 
  1. end test;  

打印出输入的时间信息

 

 
 
 
  1. E.g:   
  2. create or replace procedure test(workDate in Date) is   
  3. begin   
  4. dbms_output.putline('The input date is:'
    ||to_date(workDate,'yyyy-mm-dd'));   
  5. end test;   

 

2、变量赋值

变量名 := 值;

 

 
 
 
  1. E.g:   
  2. create or replace procedure test(workDate in Date) is   
  3. x number(4,2);   
  4. begin   
  5. :1;   
  6. end test;   

 

3、判断语句

if 比较式 then begin end; end if;

 

 
 
 
  1. E.g   
  2. create or replace procedure test(x in number) is   
  3. begin   
  4. if x >0 then   
  5. begin   
  6. :0 - x;   
  7. end;   
  8. end if;   
  9. if x = 0 then   
  10. begin   
  11. x: = 1;   
  12. end;   
  13. end if;   
  14. end test;   

上述的相关内容就是对Oracle存储过程总结的描述,希望会给你带来一些帮助在此方面。

【编辑推荐】

  1. 用触发器实现Oracle操作日志
  2. Oracle数据库中经常使用的启动方式介绍
  3. Oracle数据库中3种常用的关闭方式
  4. Oracle11g认证考试的3个主要途径
  5. Oracle SQL的优化的规则描述

 

THE END