oracle - 使用 TADOQuery 转换负数

标签 oracle delphi casting activex bcd

我在 TADOQuery 方面遇到了一个大问题:

这是我的 SQL:

select cast(-10 as number(9)) foo, -10 bar 
  from dual

当您添加“foo”字段时,将创建一个 TIntegerField,而不是 TBCDField,因为此时类型已更改:

procedure TCustomADODataSet.InternalInitFieldDefs;

    if (F.Type_ = adNumeric) and (F.NumericScale = 0) and
       (F.Precision < 10) then
      FieldType := ftInteger;

功能:

function TCustomADODataSet.GetFieldData(Field: TField; Buffer: Pointer;
  NativeFormat: Boolean): Boolean;

此时不考虑信号:

    ftAutoInc, ftInteger:
      Integer(Buffer^) := lVal;

TIntegerField 的 tagVariant 值为:

(14, 32768, 0, 0, 10, 10, 10, 1.4012984643e-44, 4.9406564584e-323, 真, 10, 0.001, 4.9406564584e-323, , $A, $A, $A, $ A、$A、$A、$A、$A、$A、$A、$A、$A、$A ''、$A、$A、$A、$A、$A、#10、10 , 10, 10, 10, $A, , $A, $A, $A, $A)

这与 TBCDField 相同:

(14, 32768, 0, 0, 10, 10, 10, 1.4012984643e-44, 4.9406564584e-323, 真, 10, 0.001, 4.9406564584e-323, , $A, $A, $A, $ A、$A、$A、$A、$A、$A、$A、$A、$A、$A ''、$A、$A、$A、$A、$A、#10、10 , 10, 10, 10, $A, , $A, $A, $A, $A)

foo 值为 10,bar 值为 -10。

这是一个错误吗?
有解决方法吗?
修好了?

我使用 Microsoft OLEDB Provider for Oracle 和 Oracle Provider for OLEDB 进行了测试。 所有测试均使用Delphi 6完成。

最佳答案

我不知道我是否理解正确,但是尝试这样:

select cast(replace(-10,'-','') as number(9)) foo, -10 bar 
  from dual;

关于oracle - 使用 TADOQuery 转换负数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16199517/

相关文章:

delphi - TEventLogger 有灯吗?

delphi - LockBox Stream 读取错误,RSA

C# 通过对象拆箱

c++ - 构造函数中的模板类转换

在包含指向不同类型的指针的结构之间转换结构指针?

使用源表中的虚拟列重写 Oracle 查询

oracle - 如何创建 Oracle 表的副本,包括触发器、序列和索引

delphi - 使用带有 Indy 的 Delphi 或 Delphi 的任何其他组件/工具检查电子邮件是否存在

sql - 从 nodejs 连接 oracle

sql - 向 UTL_MAIL.SEND 提供凭据以绕过 ORA-29278