欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle 中的类型转换函数

程序员文章站 2022-06-11 20:50:15
...

带小数点的字符串(除小数点外其它的都是数字)转换成数值 TO_NUMBER Converts a string to the NUMBER data type TO_NUMBE

带小数点的字符串(除小数点外其它的都是数字)转换成数值

TO_NUMBER

Converts a string to the NUMBER data type TO_NUMBER([, , ]) RETURN NUMBER

CREATE TABLE test (
testcol VARCHAR2(10));

INSERT INTO test VALUES ('12345.67');

SELECT TO_BINARY_DOUBLE(testcol) BIN_DOUBLE, TO_BINARY_FLOAT(testcol) BIN_FLOAT, TO_NUMBER(testcol) NMBR
FROM test;

Converts a HEX number to FLOAT TO_NUMBER(, );

SELECT TO_NUMBER('0A', 'XX')
FROM dual;

Converts a HEX number to DECIMAL TO_NUMBER(,
'') RETURN ;

SELECT TO_NUMBER(100000,'XXXXXXXX')
FROM dual;

1.语法:TO_NUMBER(string[,format[,nlsparams]])
目的:将CHAR或VARCHAR2类型的string转换为一个NUMBER类型的数值,,如果指定了format,那么string应该遵循相应的数字格式。
2.范例
DECLARE
v_Num NUMBER;
BEGIN
v_Num := TO_NUMBER( '$12345.67 ', '$99999.99 ');
END;

Oracle UTL_RAW

General Information

Source {ORACLE_HOME}/rdbms/admin/utlraw.sql

First Available 7.3.4

Constants

Name Data Type Value

Dependencies 179 objects

SELECT name FROM dba_dependencies
WHERE referenced_name = 'UTL_RAW'
UNION
SELECT referenced_name FROM dba_dependencies
WHERE name = 'UTL_RAW';

Exceptions

Error # Name Description