Oracle 中的类型转换函数

php中文网
发布: 2016-06-07 17:03:26
原创
1273人浏览过

带小数点的字符串(除小数点外其它的都是数字)转换成数值 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( '345.67 ', '999.99 ');
end;

酒店管理系统项目源码(三层开发)
酒店管理系统项目源码(三层开发)

系统采用VS2008+Sql2005开发适用于中小型的酒店管理,全部采用三层架构,ASP.NET开发,运用CSS加DIV的界面布局,完整的源代码和数据库设计,是你不可多得的参考资料。 有客房管理、房间类型管理、入住和退房管理等简单功能HotelManager为网站目录DB_51aspx下为Sql2005数据库,附加即可(Sql2000格式数据库转换后稍后发布)

酒店管理系统项目源码(三层开发) 0
查看详情 酒店管理系统项目源码(三层开发)

 

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

An arithmetic, conversion, truncation, or size-constraint error. Usually raised by trying to cram a 6 character string into a VARCHAR2(5).

Required Object Privileges GRANT execute on UTL_RAW

GRANT execute ON utl_raw TO UWCLASS;

 

BIT_AND

Perform bitwise logical "and" of the values in raw r1 with raw r2 and return the "anded" result raw utl_raw.bit_and(r1 IN RAW, r2 IN RAW) RETURN RAW;

SELECT utl_raw.bit_and('0102F3', 'F30201')
FROM dual;

 

BIT_COMPLEMENT

Perform bitwise logical "complement" of the values in raw and return the "complement'ed" result raw utl_raw.bit_complement(r IN RAW) RETURN RAW;

SELECT utl_raw.bit_complement('0102F3')
FROM dual;

 

BIT_OR

Perform bitwise logical "or" of the values in raw r1 with raw r2 and return the "or'd" result raw utl_raw.bit_or(r1 IN RAW, r2 IN RAW) RETURN RAW;

SELECT utl_raw.bit_or('0102F3', 'F30201')
FROM dual;

 

BIT_XOR

Perform bitwise logical "exclusive or" of the values in raw r1 with raw r2 and return the "xor'd" result raw utl_raw.bit_xor(r1 IN RAW, r2 IN RAW) RETURN RAW;

SELECT utl_raw.bit_xor('0102F3', 'F30201')
FROM dual;

 

CAST_FROM_BINARY_DOUBLE

Return the RAW representation of a binary_double value utl_raw.cast_from_binary_double(n IN BINARY_DOUBLE,
endianess IN PLS_INTEGER DEFAULT 1) RETURN RAW;

SELECT utl_raw.cast_from_binary_double(123.45)
FROM dual;

 

CAST_FROM_BINARY_FLOAT

Return the RAW representation of a binary_float value utl_raw.cast_from_binary_float(n IN BINARY_FLOAT,
endianess IN PLS_INTEGER DEFAULT 1) RETURN RAW;

SELECT utl_raw.cast_from_binary_float(123.45)
FROM dual;

 

CAST_FROM_BINARY_INTEGER

Return the RAW representation of a binary_integer value utl_raw.cast_from_binary_integer(
n         IN BINARY_INTEGER,
endianess IN PLS_INTEGER DEFAULT 1) RETURN RAW;

SELECT utl_raw.cast_from_binary_integer(100)
FROM dual;

 

CAST_FROM_NUMBER

Returns the binary representation of a NUMBER in RAW utl_raw.cast_from_number(n IN NUMBER) RETURN RAW;

SELECT utl_raw.cast_from_number(100)
FROM dual;

 

CAST_TO_BINARY_DOUBLE

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号