sql_lFUNCTION

CREATE OR REPLACE FUNCTION f_WorkDay( contractNumber VARCHAR2 ) RETURN Date 
is 
v_begin date;--返回日期
begin --开始

select t.loan_time v_begin into v_begin  from cs_contract t where t.contract_number=contractNumber;--根据合同编号查询返回日期

if   trunc(v_begin)  >  trunc(sysdate) then  
 
 v_begin :=sysdate;   --给变量赋值
 
 else
   
 v_begin:=v_begin;    --给变量赋值
 
 end if;
 
 return v_begin;     --返回结果


end f_WorkDay;--结束



--调用

select f_workday('GZ-A-2013000412') as 结果日期 from dual;

 

posted @ 2014-12-31 09:30  也许还年轻  阅读(111)  评论(0编辑  收藏  举报