龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 数据库类 > Oracle 技术 >

Oracle存储过程的创建

时间:2011-04-12 23:18来源:未知 作者:admin 点击:
分享到:
本人是Oracle 的热捧者,以下的相关内容主要是我个人对于 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存储过程总结的描述,希望会给你带来一些帮助在此方面。

精彩图集

赞助商链接