您好,欢迎访问一九零五行业门户网

Oracle 中的类型转换函数

带小数点的字符串(除小数点外其它的都是数字)转换成数值 to_number converts a string to the number data type to_numbe
带小数点的字符串(除小数点外其它的都是数字)转换成数值
to_number
converts a string to the number data typeto_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 floatto_number(, );
select to_number('0a', 'xx')
from dual;
converts a hex number to decimalto_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 available7.3.4
constants
namedata typevalue
dependencies179 objects
select name from dba_dependencies
where referenced_name = 'utl_raw'
union
select referenced_name from dba_dependencies
where name = 'utl_raw';
exceptions
error #namedescription
an arithmetic, conversion, truncation, or size-constraint error. usually raised by trying to cram a 6 character string into a varchar2(5).
required object privilegesgrant 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 rawutl_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 rawutl_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 rawutl_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 rawutl_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 valueutl_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 valueutl_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 valueutl_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 rawutl_raw.cast_from_number(n in number) return raw;
select utl_raw.cast_from_number(100)
from dual;
cast_to_binary_double
其它类似信息

推荐信息