oracle自定义函数的执行时间[2]
文章作者 100test 发表时间 2007:06:08 11:29:47
来源 100Test.Com百考试题网
-- 检查是否全为数字,否则转换操作会抛异常,导致程序崩溃,ascii( 0 ) = 48, ascii( 9 ) = 57
--for i in 1 .. 15 loop
WHILE i <= 15 LOOP
--ch := substr(id, i, 1). -- 非数字会报错
c := ascii(substr(id, i, 1)).
if c < 48 or c > 57 then
exit.
end if.
i := i 1.
end loop.
IF i = 16 THEN
trans := TRUE.
ret := 19 || substr(id, 7, 2).
END IF.
end if.
if (len = 18) then
-- 2006-10-18 luocm
-- 检查是否全为数字,否则转换操作会抛异常,导致程序崩溃,ascii( 0 ) = 48, ascii( 9 ) = 57
--for i in 1 .. 17 loop
WHILE i <= 17 LOOP
--ch := substr(id, i, 1). -- 非数字会报错
c := ascii(substr(id, i, 1)).
if c < 48 or c > 57 then
exit.
end if.
i := i 1.
end loop.
c := ascii(substr(id, 18, 1)).
--if i <> 18 OR (c <> 88 AND c <> 120) OR c < 48 or c > 57 THEN -- 第18位为[0-9xX]
if i = 18 AND (c = 88 OR c = 120 OR c >= 48 or c <= 57) THEN -- 第18位为[0-9xX]
trans := TRUE.
ret := substr(id, 7, 4).
end if.
end if.
IF trans = FALSE THEN
i := 1.
WHILE i <= 8 LOOP
c := ascii(substr(birthday, i, 1)).
if c < 48 or c > 57 then
exit.
end if.
i := i 1.
end loop.
IF i > 8 THEN
yyyy := substr(ltrim(rtrim(birthday)), 1, 4).
IF yyyy < 1900 OR yyyy > 2000 THEN
ret := .
ELSE
ret := yyyy.
END IF.
ELSE
ret := yyyy.
END IF.
END IF.
RETURN ret.
end f_extract_birthday.
src="/oracle/js/wxgg_oracle.js">