Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
  HXTT Excel v6.1
  HXTT Json v1.0
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Word v1.1
  HXTT XML v4.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT Text(CSV)
BINARY conversions
Martin Ross
2006-06-24 15:56:29
It would be nice to have support to be able to cast short binary types into primative number types.

create table test
(
test1 BINARY(2)
)

select cast(test1 as SMALLINT) from test

select cast(test1 as BIGINT) from test


I would suggest that restriction is placed on BINARY size to avoid overflows/meaningless conversions

create table test
(
test1 BINARY(8)
)

select cast(test1 as SMALLINT) from test should return an error.

Obviously endianness would be a conern so a function to reverse endianness would be helpful too. i.e. SwapBytes().

Also ability to handle BINARY of odd sizes.
e.g. create table test
(
test 1 BINARY(3)
)
select cast(test1 as BIGINT) from test from should work.
Re:BINARY conversions
HXTT Support
2006-06-24 21:49:25
Please download the latest package, which has provide these functions below:
BToInt_LE(binary): get int value from bytes with little-endian.
BToInt_BE(binary): get int value from bytes with big-endian.
IntToB_LE(binary): get bytes with little-endian from int value.
IntToB_BE(binary): get bytes with big-endian from int value.
BToShort_LE(binary): get short value from bytes with little-endian.
BToShort_BE(binary): get short value from bytes with big-endian.
ShortToB_LE(binary): get bytes with little-endian from short value.
ShortToB_BE(binary): get bytes with big-endian from short value.
BToLong_LE(binary): get long value from bytes with little-endian.
BToLong_BE(binary): get long value from bytes with big-endian.
LongToB_LE(binary): get bytes with little-endian from long value.
LongToB_BE(binary): get bytes with big-endian from long value.


Tested sqls:
create table test ( test1 BINARY(2) )
select btoshort_be(test1) from test

select btolong_be(test1) from test

create table test1 ( test1 BINARY(8))

select btoshort_be(test1) from test1

create table test2 ( test1 BINARY(3) );
select btolong_be(test1)from test2


Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Sitemap