帮助按字节处理整数字节 [英] Help Processing Integer Byte by Byte

查看:62
本文介绍了帮助按字节处理整数字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

整数仅使用4个字节存储在表中。是否有一种方法在

SQL中检索实际存储的值,而不是将
转换回显示的数字?


例如,如果我有2030906,它将以4个字节存储。可以写一个

查询给我4个字节,而不是2030906.

卸载,这是自动完成的,可以在SQL中完成吗? />

谢谢!

ML

解决方案

ML写道:


整数仅使用4个字节存储在表中。是否有一种方法在

SQL中检索实际存储的值,而不是将
转换回显示的数字?


例如,如果我有2030906,它将以4个字节存储。可以写一个

查询给我4个字节,而不是2030906.

卸载,这是自动完成的,可以在SQL中完成吗?



使用HEX()函数。请注意,此类代码不可移植,因为

存储取决于CPU架构。


干杯

Serge

-

Serge Rielau

DB2解决方案开发

IBM多伦多实验室

2月20日上午8:24,Serge Rielau< srie ... @ ca.ibm.comwrote:


ML写道:


整数仅使用4个字节存储在表中。是否有一种方法在

SQL中检索实际存储的值,而不是将
转换回显示的数字?


例如,如果我有2030906,它将以4个字节存储。可以写一个

查询给我4个字节,而不是2030906.

卸载,这是自动完成的,可以在SQL中完成吗?



使用HEX()函数。请注意,此类代码不可移植,因为

存储取决于CPU架构。


干杯

Serge


-

Serge Rielau

DB2解决方案开发

IBM多伦多实验室



是的,到目前为止。我可以将上面的数字检索到001EFD3A。

我现在要做的是将001EFD3A恢复为char(4)

字段。我需要在SQL中完成所有这些,但不是程序。


具体来说,我想要一个char(2)和一个整数并存储

他们进入char(6)领域(不要问为什么!)。我需要在

触发器中执行此操作。


下一步是什么?


谢谢!

ML


2007年2月20日06:50:15 -0800,ML < li ********* @ gmail.comwrote:


> 2月20日上午8:24,Serge Rielau< srie。 .. @ ca.ibm.comwrote:


> ML写道:


整数存储在表只使用4个字节。是否有一种方法在

SQL中检索实际存储的值,而不是将
转换回显示的数字?


例如,如果我有2030906,它将以4个字节存储。可以写一个

查询给我4个字节,而不是2030906.

卸载,这是自动完成的,可以在SQL中完成吗?


使用HEX()函数。请注意,此类代码不可移植,因为存储取决于CPU架构。

Serge

-
Serge Rielau
DB2解决方案开发
IBM多伦多实验室



是的,到目前为止。我可以将上面的数字检索到001EFD3A。
我现在要做的是将001EFD3A恢复到char(4)
字段。



嗯?


B.


我需要在SQL中完成所有这些,但不是程序。
具体来说,我想要一个char(2)和一个整数并将它们存储到char(6)字段中(别问为什么!)。我需要在
触发器中执行此操作。

下一步是什么?

谢谢!
ML


Integers are stored in tables using only 4 bytes. Is there a way in
SQL to retrieve the value as it is actually stored, not converted back
into the displayed number?

For example, if I have 2030906, it gets stored in 4 bytes. Can a
query be written to give me the 4 bytes back, not 2030906. On an
unload, this is done automatically, can it be done in SQL?

Thank!
ML

解决方案

ML wrote:

Integers are stored in tables using only 4 bytes. Is there a way in
SQL to retrieve the value as it is actually stored, not converted back
into the displayed number?

For example, if I have 2030906, it gets stored in 4 bytes. Can a
query be written to give me the 4 bytes back, not 2030906. On an
unload, this is done automatically, can it be done in SQL?

Use the HEX() function. Note that such code will NOT be portable because
the storage depends on the CPU architecture.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


On Feb 20, 8:24 am, Serge Rielau <srie...@ca.ibm.comwrote:

ML wrote:

Integers are stored in tables using only 4 bytes. Is there a way in
SQL to retrieve the value as it is actually stored, not converted back
into the displayed number?

For example, if I have 2030906, it gets stored in 4 bytes. Can a
query be written to give me the 4 bytes back, not 2030906. On an
unload, this is done automatically, can it be done in SQL?


Use the HEX() function. Note that such code will NOT be portable because
the storage depends on the CPU architecture.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Yep, got that far. I can retrieve the above number into 001EFD3A.
What I want to do now is to restore that 001EFD3A into a char(4)
field. I need to do all this in SQL, though, not a program.

Specifically, I am wanting to take a char(2) and an integer and store
them into a char(6) field (don''t ask why!). I need to do this in a
trigger.

What next?

Thanks!
ML


On 20 Feb 2007 06:50:15 -0800, "ML" <li*********@gmail.comwrote:

>On Feb 20, 8:24 am, Serge Rielau <srie...@ca.ibm.comwrote:

>ML wrote:

Integers are stored in tables using only 4 bytes. Is there a way in
SQL to retrieve the value as it is actually stored, not converted back
into the displayed number?

For example, if I have 2030906, it gets stored in 4 bytes. Can a
query be written to give me the 4 bytes back, not 2030906. On an
unload, this is done automatically, can it be done in SQL?


Use the HEX() function. Note that such code will NOT be portable because
the storage depends on the CPU architecture.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab



Yep, got that far. I can retrieve the above number into 001EFD3A.
What I want to do now is to restore that 001EFD3A into a char(4)
field.

Huh?

B.

I need to do all this in SQL, though, not a program.
Specifically, I am wanting to take a char(2) and an integer and store
them into a char(6) field (don''t ask why!). I need to do this in a
trigger.

What next?

Thanks!
ML


这篇关于帮助按字节处理整数字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆