Oracle硬编码/计算列数据类型 [英] Oracle hardcoded/computed column datatypes
问题描述
是否可以在Oracle中设置硬编码或计算列的数据类型.
Is it possible to set the datatype of hardcoded or computed columns in Oracle.
例如:
SELECT AccountID FROM Account
当我阅读返回到.Net的记录时,可以使用整数获取accountID.
When I read through the records returned to .Net, I can fetch the accountID using an integer.
_accountID = dr.GetInteger("accountID")
但是,如果我有一个UNION
查询,例如:
However say if I have a UNION
query, eg:
SELECT AccountID FROM Account
UNION
SELECT 0 as AccountID FROM Account
我得到一个错误:"Specified cast is not valid."
,因为只能使用双精度值来检索硬编码的0列.
I get an Error: "Specified cast is not valid."
because the hardcoded 0 column can only be retrieved using a double.
_accountID = dr.GetDouble ("accountID")
是否有一种方法可以强制Oracle以NUMBER(9)
或float
的形式返回数字计算的列?
Is there a way to force Oracle to return numeric computed columns as a NUMBER(9)
or float
?
推荐答案
因为这很紧急,所以我打算使用GetDouble作为整数以及硬编码/计算数字列.如果有人知道的更好,请告诉我.
since this is urgent I'm just going to settle for using the GetDouble for integers as well as hardcoded/computed numeric columns. If anyone knows better please let me know.
这篇关于Oracle硬编码/计算列数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!