17,088
社区成员
发帖
与我相关
我的任务
分享
create or replace function GETLASTLESSENDATE(CRIMINALNOWINFOID in NUMBER) return date is
Result date;
startdate date;
begin
begin
select c.xfbd23 into startdate from (
select sc.xfbd23
from sentence_change sc
where sc.state = '已通过'
and sc.criminal_now_info_id = CRIMINALNOWINFOID
and (sc.xfbd01=7 or sc.xfbd01=8 or sc.xfbd01 =9 or sc.xfbd01 =10)
order by sc.xfbd23 desc
) c
where rownum = 1;
Result := startdate;
return(Result);
exception
when others when
return 指定日期;
end;
........;
end GETLASTLESSENDATE;
create or replace function GETLASTLESSENDATE(CRIMINALNOWINFOID in NUMBER) return date is
Result date;
startdate date;
begin
select c.xfbd23 into startdate from (
select sc.xfbd23
from sentence_change sc
where sc.state = '已通过'
and sc.criminal_now_info_id = CRIMINALNOWINFOID
and (sc.xfbd01=7 or sc.xfbd01=8 or sc.xfbd01 =9 or sc.xfbd01 =10)
order by sc.xfbd23 desc
) c
where rownum = 1;
Result := startdate;
return(Result);
exception
when others when
return null;
end GETLASTLESSENDATE;
--例如:
create or replace function GETLASTLESSENDATE(CRIMINALNOWINFOID in NUMBER)
return date
is
Result date;
startdate date;
begin
select c.xfbd23 into startdate from (
select sc.xfbd23 from sentence_change sc
where sc.state = '已通过'
and sc.criminal_now_info_id = CRIMINALNOWINFOID
and (sc.xfbd01=7 or sc.xfbd01=8 or sc.xfbd01 =9 or sc.xfbd01 =10)
order by sc.xfbd23 desc
) c
where rownum = 1;
Result := startdate;
return Result;
exception when no_data_found then --捕获异常,返回空的日期
return to_date(null);
end GETLASTLESSENDATE;
--比如说如果c.xfbd23为空的话返回当前的系统时间
select nvl(c.xfbd23,sysdate) into startdate from
--或者用exception
exception when no_data_found then
result:=sysdate;