简体   繁体   English

在 Firebird 3.0 bigint 与 Firebird 2.5 integer 中计数

[英]Count in Firebird 3.0 bigint vs Firebird 2.5 integer

On my system, after the migration from Firebird 2.5 to 3.0, many reports and other functions began to give problems stating that what was expected was Integer and the current one is LargeInt .在我的系统上,从 Firebird 2.5 迁移到 3.0 后,许多报告和其他函数开始出现问题,指出预期的是 Integer 而当前的是LargeInt I took a look and saw that some searches with the count in 3.0 return a bigInt column, while in 2.5 it returns an integer column.我看了一下,在 3.0 中使用计数的一些搜索返回一个bigInt列,而在 2.5 中它返回一个整数列。

To solve the way I know, I would have to cast a cast on everything that is giving error, tested and worked, but it is a big system, it will give a lot of work.为了解决我所知道的方式,我必须对所有出现错误、经过测试和工作的东西进行强制转换,但它是一个大系统,它将提供大量工作。

Does anyone know of any way to resolve this in Firebird itself?有谁知道在 Firebird 本身中有什么方法可以解决这个问题? Some configuration, or something?一些配置,还是什么?

There is no configuration for it;没有它的配置; the Firebird 3 release notes only say : Firebird 3 发行说明只说

The COUNT() aggregator now returns its result as BIGINT instead of INTEGER . COUNT()聚合器现在将其结果返回为BIGINT而不是INTEGER

You either need to explicitly apply a cast in your queries, or in your code, or see if your data access library can explicitly request integer instead of just the dynamic type.您需要在查询或代码中显式应用强制转换,或者查看您的数据访问库是否可以显式请求整数,而不仅仅是动态类型。 For example in the Java world the JDBC API has an explicit getInt which will work for BIGINT as long as the value fits in a 32 bit integer.例如,在 Java 世界中,JDBC API 有一个显式的getInt ,只要该值适合 32 位整数, getInt可以用于BIGINT

我使用 Unidac,对于解决方案,我使用了 Map Rules(数据类型映射)。

Use TYPECAST in SQL in any delphi component and will be ok.在任何 delphi 组件中使用 SQL 中的 TYPECAST 就可以了。 For example wite:例如白:

select
cast(count(*) as integer) BR
from ...

instead of代替

select
count(*) BR
from ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM