Oraclec创建函数的语法规则

   create or replace function  函数名 (参数名1 参数类型,参数名2 参数类型)  return number  is

   Result number ;

 begin 

          return (Result);

  end;

 例子 : 根据工号返回城市的函数

    Orcale创建函数(function)

   调用函数

   Orcale创建函数(function)

  •  根据日期,返回时上半年还是下半年(上半年1,下半年2)
    --根据日期获取上半年还是下半年
    CREATE OR REPLACE FUNCTION getYearHalf(iDate Date)
    RETURN number is
    month char(2);
    half number;
    begin 
      select to_char(iDate,'MM') into month from dual;
      half :=to_number(month) ;
      if half>6 then 
        half:=2;
        else 
          half:=1;
          end if;
      return half;
      end;
    View Code

相关文章:

  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2021-06-26
  • 2022-12-23
  • 2022-02-25
  • 2021-07-14
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2021-06-18
  • 2022-12-23
  • 2021-12-19
  • 2021-11-18
  • 2021-05-17
相关资源
相似解决方案