日期:2014-05-16  浏览次数:20528 次

创建函数样例
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;
/