问题描述:查字符类型转换date类型值时报错“ORA-00904: "GET_INTERNAL_VALUE": invalid identifier”,如下所示:
数据库:oracle 11.2.0.4
1、异常重现
SYS@orcl> select get_internal_value('DF2304290000748902') from dual;
select get_internal_value('DF2304290000748902') from dual
*
ERROR at line 1:
ORA-00904: "GET_INTERNAL_VALUE": invalid identifier
2、解决过程
SYS@orcl> CREATE OR REPLACE FUNCTION get_internal_value(p_value IN VARCHAR2)
RETURN VARCHAR2 IS
FOR i IN 1 .. 15 LOOP
temp_n NUMBER := 0;
ASCII(SUBSTR(RPAD(p_value, 15, CHR(0)), i, 1));
BEGIN
RETURN TO_CHAR(ROUND(temp_n, -21));
FOR i IN 1 .. 15 LOOP
WHEN OTHERS THEN
temp_n := temp_n + POWER(256, 15 - i) *
END get_internal_value;
ASCII(SUBSTR(RPAD(p_value, 15, CHR(0)), i, 1));
END LOOP;
RETURN TO_CHAR(ROUND(temp_n, -21));
EXCEPTION
WHEN OTHERS THEN
RETURN p_value;
END get_internal_value;
14 /
Function created.
SYS@orcl> select get_internal_value('DF2304290000748902') from dual;
GET_INTERNAL_VALUE('DF2304290000748902')
----------------------------------------------------------------------
354499932302760000000000000000000000
3、拓展知识
--创建get_external_value函数.
CREATE OR REPLACE FUNCTION get_external_value(p_value IN VARCHAR2)
RETURN VARCHAR2 IS
temp_n NUMBER;
temp_i INTEGER;
my_result VARCHAR2(32767) := NULL;
BEGIN
IF LENGTH(p_value) 36 OR
SUBSTR(p_value, 16) '000000000000000000000' OR
p_value > POWER(256, 15) OR p_value select get_internal_value('2022-05-31') a,get_internal_value('2022-06-02') b from dual
A B
---------------------------------------- ----------------------------------------
260592375524722000000000000000000000 260592375524722000000000000000000000
注意:对于varchar2类型的字段保留日期记录,跨月查询可能会导致执行计划异常.
参考网址:https://blog.51cto.com/hunt1574/5462623
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: elk之[logstash-input-file]插件使用详解
https://www.elastic.co/guide/en/logstash/current/index.html 官方文档 一、安装配置kibana 5.1 下载解压缩 [admin@node21 elk]$ wget https://art…