I am querying an Oracle 10g database using OleDb.
My query is very simple, just getting a COUNT of records from a given table.
In using ExecuteScalar, I ran into conversion errors trying to convert the result value to Int. In checking the type, it turns out to be System.Decimal.
Now, I’ve seen elsewhere users having similar issues with IDs, but in this case I am simply returning a count that is expected to be an Integer, so why would I still have to cast it?
The SQL is below.
_sqlText = @" select count(*) as num_records from ce_quote_ext
where ce_quoteid in (select ce_quoteid from ce_quote where opportunityid in
(select opportunityid from ce_quote where ce_quoteid = '?' )) and custsign = 'T' ";
It’s really the Oracle OleDb library that’s returning a decimal. This is correct behavior. See here for the Oracle documentation. In the example in the Oracle documentation, they are casting the return of a COUNT() function into a decimal. So, it appears by design.