Oracle 硬编码/计算列数据类型
是否可以在 Oracle 中设置硬编码或计算列的数据类型。
例如::
SELECT AccountID FROM Account
当我读取返回到.Net的记录时,我可以使用整数获取accountID。
_accountID = dr.GetInteger("accountID")
但是,如果我有一个 UNION
查询,例如:
SELECT AccountID FROM Account
UNION
SELECT 0 as AccountID FROM Account
我收到错误:“指定的转换无效。”
因为硬编码的 0 列只能使用 double 来检索。
_accountID = dr.GetDouble ("accountID")
有没有办法强制 Oracle 将数字计算列返回为 NUMBER(9)
或 float
?
Is it possible to set the datatype of hardcoded or computed columns in Oracle.
For example::
SELECT AccountID FROM Account
When I read through the records returned to .Net, I can fetch the accountID using an integer.
_accountID = dr.GetInteger("accountID")
However say if I have a UNION
query, eg:
SELECT AccountID FROM Account
UNION
SELECT 0 as AccountID FROM Account
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")
Is there a way to force Oracle to return numeric computed columns as a NUMBER(9)
or float
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请尝试此操作,
从帐户联合中选择 Account_id select cast( 0 as number(9)) as Account_id from Account
或
从帐户联合中选择 Account_id select cast( 0 as float(9)) as Account_id from Account
Please try this,
select Account_id from Account union select cast( 0 as number(9)) as Account_id from Account
or
select Account_id from Account union select cast( 0 as float(9)) as Account_id from Account
我只是打算使用 GetDouble 来处理整数以及硬编码/计算的数字列。如果有人知道更好请告诉我。
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.