orcle函数的使用,及其调用
Posted 学无止境,前进
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了orcle函数的使用,及其调用相关的知识,希望对你有一定的参考价值。
CREATE OR REPLACE Function getBdateT(
D_Build date,
Q_Date date
) return Date as
D_Return Date; /*返回的日期*/
Q_Year int := 1;/*查询日期的年份*/
Q_Quartar int := 1;/*查询日期的季度*/
D_Year int := 1;/*成立日期的年份*/
D_Quartar int := 1;/*成立日期的季度*/
begin
/* 赋初始值*/
D_Return := sysdate;
select extract(year from Q_Date) into Q_Year from dual ;
select extract(year from D_Build) into D_Year from dual ;
select TO_NUMBER(TO_CHAR(Q_Date,‘Q‘)) into Q_Quartar from dual ;
select TO_NUMBER(TO_CHAR(D_Build,‘Q‘)) into D_Quartar from dual ;
if (Q_Year = D_Year AND D_Quartar =Q_Quartar) then
D_Return := D_Build;
else
D_Return := Q_Date;
end if;
return D_Return;
end;
-------------------------------------------------------------------------
函数的调用
select getBdateT(date‘2016-05-01‘,date‘2016-05-04‘) from dual
select * from ta ,t_p_ab_port t1 where ta. c_pot_code = t1.c_port_code and ta.c_Port_code in (sdfsdf) and ta.rq in (cxrq , getBdateT(t1.d_build,cxrq) )
以上是关于orcle函数的使用,及其调用的主要内容,如果未能解决你的问题,请参考以下文章