cfqueryparam 中 Oracle 的 Number(*,0) 数据类型使用哪种 cfsqltype?

Which cfsqltype to use for Oracle's Number(*,0) datatype in cfqueryparam?

我有点困惑我应该为 Oracle Number(*,0) 使用零标度和任何精度的数据类型?

我应该使用 CF_SQL_INTEGER 还是 CF_SQL_FLOAT 哪一个?为什么?

根据文档,Number(*,0) 表示您使用的是非常大的整数,即最多 38 位数字且没有小数位:

column_name NUMBER (precision, scale)

... precision (total number of digits) and scale (number of digits to the right of the decimal point):

column_name NUMBER (*, scale)

In this case, the precision is 38, and the specified scale is maintained.

CF_SQL_INTEGER 中存储的位数太多。要支持全范围,需要容量更大的类型。查看用于存储的标准 JDBC Mappings that means either java.sql.Types.NUMERIC or java.sql.Types.DECIMAL. Both of those use java's BigDecimal,其容量足以 Number(38,0)

cfqueryparam matrix and Oracle JDBC driver 文档都对 DECIMAL 类型说了同样的话。由于 java.sql.Types.NUMERIC 实际上只是 java.sql.Types.DECIMAL 的同义词,您可以使用其中任何一个。

注意:使用cfqueryparam时,如果省略"scale"属性,则默认scale="0",即无小数位。

    <cfqueryparam type="CF_SQL_DECIMAL" scale="0" value="....">