开发者

Oracle hardcoded/computed column datatypes

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 开发者_StackOverflowonly 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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜