解决方案 »
- RMAN两个问题
- 如何恢复oracle表名
- 求救 Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870080)(ERR=12518)(ERROR_STACK=(ERROR=(
- print时碰到"字符串缓冲太小"的问题,快被郁闷坏了.
- Oracle数据库工程师培训视频资料下载
- 关于USER_CONS_COLUMNS表的问题
- 排序的问题
- 很菜的问题!请问这句话:SELECT TO_DATE('1999-8-9 14:18:35' ,'yyyy-mm-dd') FROM DUAL;错在哪儿?解决马上给分
- 怎样用wrap23命令加密过程?
- 请问哪里有介绍oracle函数的文档?
- 定时任务如何设置
- oracle dg 不能同步
如果你使用pl/sql developer ,可以按住ctrl,点击这个函数,查看它是如何定义的。
应该是自定义的函数,oracle自身没有这个
return date
as
v_date date;
v_s1 varchar2(50):='12-12月-11';
v_s varchar2(30);
v1 integer;
v2 integer;
v3 integer;
begin
v_s1:=p_date;
case when (p_date like '%JAN%') then v_s1:=replace(p_date,'MAR','1月');
when (p_date like '%FEB%') then v_s1:=replace(p_date,'FEB','2月');
when (p_date like '%MAR%') then v_s1:=replace(p_date,'MAR','3月');
when (p_date like '%APR%') then v_s1:=replace(p_date,'APR','4月');
when (p_date like '%MAY%') then v_s1:=replace(p_date,'MAY','5月');
when (p_date like '%JUN%') then v_s1:=replace(p_date,'JUN','6月');
when (p_date like '%JUL%') then v_s1:=replace(p_date,'JUL','7月');
when (p_date like '%AUG%') then v_s1:=replace(p_date,'AUG','8月');
when (p_date like '%SEP%') then v_s1:=replace(p_date,'SEP','9月');
when (p_date like '%OCT%') then v_s1:=replace(p_date,'OCT','10月');
when (p_date like '%NOV%') then v_s1:=replace(p_date,'NOV','11月');
when (p_date like '%DEC%') then v_s1:=replace(p_date,'DEC','12月');
else null;
end case;
if (instr(v_s1,'月')>0 and p_bz=0) then
v1:=instr(v_s1,'-');
v2:=instr(v_s1,'月');
v3:=instr(v_s1,'-',1,2);
v_s:=substr(v_s1,v3+1,length(v_s1))||'-'||substr(v_s1,v1+1,v2-v1-1)||'-'||substr(v_s1,1,v1-1);
v_date:=to_date(trim(v_s),'yy-mm-dd');
return v_date;
end if;
if (p_bz<=1) then
v_date:=to_date(trim(p_date),'yyyy-mm-dd');
return v_date;
end if;
end;就只这个方法,好像只是转换一下日期格式的方法,求赐教
return date
as
v_date date;
v_s1 varchar2(50):='12-12月-11';
v_s varchar2(30);
v1 integer;
v2 integer;
v3 integer;
begin
v_s1:=p_date;
case when (p_date like '%JAN%') then v_s1:=replace(p_date,'MAR','1月');
when (p_date like '%FEB%') then v_s1:=replace(p_date,'FEB','2月');
when (p_date like '%MAR%') then v_s1:=replace(p_date,'MAR','3月');
when (p_date like '%APR%') then v_s1:=replace(p_date,'APR','4月');
when (p_date like '%MAY%') then v_s1:=replace(p_date,'MAY','5月');
when (p_date like '%JUN%') then v_s1:=replace(p_date,'JUN','6月');
when (p_date like '%JUL%') then v_s1:=replace(p_date,'JUL','7月');
when (p_date like '%AUG%') then v_s1:=replace(p_date,'AUG','8月');
when (p_date like '%SEP%') then v_s1:=replace(p_date,'SEP','9月');
when (p_date like '%OCT%') then v_s1:=replace(p_date,'OCT','10月');
when (p_date like '%NOV%') then v_s1:=replace(p_date,'NOV','11月');
when (p_date like '%DEC%') then v_s1:=replace(p_date,'DEC','12月');
else null;
end case;
if (instr(v_s1,'月')>0 and p_bz=0) then
v1:=instr(v_s1,'-');
v2:=instr(v_s1,'月');
v3:=instr(v_s1,'-',1,2);
v_s:=substr(v_s1,v3+1,length(v_s1))||'-'||substr(v_s1,v1+1,v2-v1-1)||'-'||substr(v_s1,1,v1-1);
v_date:=to_date(trim(v_s),'yy-mm-dd');
return v_date;
end if;
if (p_bz<=1) then
v_date:=to_date(trim(p_date),'yyyy-mm-dd');
return v_date;
end if;
end;是这个方法,好像只是转换一下日期格式的方法,求赐教
参数1 字符串 日期格式的字符串 满足掩码 DD-MON-YY或YYYY-MM-DD
参数2 整形 标识传入的参数1使用的那种掩码 0对应DD-MON-YY,1或负数对应YYYY-MM-DD
DD-MON-YY 这个掩码的问题,因为掩码中的年份采用的是YY的掩码,只有年份的最后两位数字,年份有时返回是错误的
执行结果为2099-8-1
DD-MON-YY 这个掩码的问题,因为掩码中的年份采用的是YY的掩码,只有年份的最后两位数字,年份有时返回是错误的您的意思就是如果我的数据是1999年,使用toxdate()这个函数查询的时候可能它查到的是2099年的,这样就查不出我想要的数据了,是这个意思么?那我应该怎么改一下使能够获得我想要的时间段的数据呢?自定义函数不可以改变,第一句的查询语句也没法改。O(∩_∩)O谢谢!
难道你数据库存储的是字符串格式‘12-12月-11’这种格式的数据
既然是日期型 为啥还通过toxdate函数转一遍再返回日期型。感觉有点匪夷所思
这边的流程是这样的,数据是从excle表中通过odi得到的,到达C$_0ZJK_MINZJ_STFQYDJ_1406这张表,这个表里面的格式都是varchar型,然后再由这个表到达ZJK_MINZJ_STFQYDJ_1406这个表就是和规定的excle表的类型一样,clrq这个在excle中是日期型的,在C$_0ZJK_MINZJ_STFQYDJ_1406中是varchar型
既然是日期型 为啥还通过toxdate函数转一遍再返回日期型。感觉有点匪夷所思
可能是因为数据是通过excle表得到的,不能确定都是日期型,只好这样转一下(个人见解,非本人开发)