码迷,mamicode.com
首页 > 数据库 > 详细

oracle----procedure

时间:2018-06-02 22:20:38      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:where   存储过程   1.2   行修改   赋值   ora   rom   type   output   

--初步认识oracle--procedure,

--1.1创建一个完整的procedure,格式如下

create or replace procedure  procedure_name 

is/as

begin

主体

exception

异常处理主体

end procedure ;

procedure_name 是过程名

or replace  则用来覆盖同过程名的过程的,如果创建的时候,不加or replace 而你创建的过程名又正好存在,就会报错

 

 参数类型:in

输入型参数,表示这个参数值可以输入给过程,供过程使用,是默认类型,不能进行修改。

参数类型:out

输出型参数,表示这个参数在过程中被赋值,可以提供给过程体以为的部分或环境。

参数类型:in out

输入输出型参数 既可以接收传入的实参值,也可以被子程序修改,可以输出

 

例如:

create or replace procedure   comunt_num

(in_sex in teaches.sex%type)

 as

out_num number;

begin

if in_sex=‘M‘ then

select count(SEX) into out_num from teachers where sex=‘M‘;

dbms_output.put_line(‘number of male teachers:‘|| out_num);

else

select count(sex) into out_num from teachers where sex=‘F‘;

dbms_output.put_line(‘number of female teachers:‘|| out_number);

end if ;

end conut_num;

1.2储过程的调用:

execute 存储过程名  参数;

1.3存储过程的删除:

drop procedure  存储过程名

 

oracle----procedure

标签:where   存储过程   1.2   行修改   赋值   ora   rom   type   output   

原文地址:https://www.cnblogs.com/supermwb/p/9098912.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!