首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

创设函数样例

2012-07-25 
创建函数样例create or replace procedure function_procedure AS i_count integerbeginselect count(*)

创建函数样例
create or replace procedure function_procedure
AS
i_count integer;
begin
  select count(*) into i_count from user_objects t where t.OBJECT_TYPE ='FUNCTION' and t.OBJECT_NAME = upper('function_name');
    if i_count>0 then
        EXECUTE IMMEDIATE 'drop function function_name';
    end if;
   
end init_function_procedure;
/
call function_procedure();
drop procedure function_procedure;

create or replace function function_name(type in INTEGER) return number is
  result number;
begin
  if(type=1) then
     result:=300/100;
  elsif (type=2) then
     result:=300/200;
  elsif (type=3) then
     result:=300/300;
  end if;

  return(result);
end function_name;
/

热点排行