Search code examples
oracle-databasetypescalculated-columns

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 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?


Solution

  • 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.