InvalidCastException
-
- Posts: 9
- Joined: Wed 02 Apr 2008 13:35
InvalidCastException
Hi,
when I try to get the value of an attribute on an OracleObejct, an InvalidCastException is thrown.
This happens, when
1. the DataType is NUMBER
2. and the attribute is not initialized (the value is NULL on the Oracle side)
I have just updated from 4.75 to the most recent version, and before the update this exception was not thrown.
Is there a way to avoid the exception, e.g. by checking for a NULL value before accessing the attribute?
##### EDIT #########
This only happens, when the indexer with the attribute-name is used.
GetOracleValue returns a double (0.0) instead of an OracleNumber with the IsNull property set to true.
So, there is a way to avoid the exception, but I still think the behavior is not correct.
##################
Kind regards,
Thomas Hoekstra
when I try to get the value of an attribute on an OracleObejct, an InvalidCastException is thrown.
This happens, when
1. the DataType is NUMBER
2. and the attribute is not initialized (the value is NULL on the Oracle side)
I have just updated from 4.75 to the most recent version, and before the update this exception was not thrown.
Is there a way to avoid the exception, e.g. by checking for a NULL value before accessing the attribute?
##### EDIT #########
This only happens, when the indexer with the attribute-name is used.
GetOracleValue returns a double (0.0) instead of an OracleNumber with the IsNull property set to true.
So, there is a way to avoid the exception, but I still think the behavior is not correct.
##################
Kind regards,
Thomas Hoekstra
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
Could you please specify how exactly you are retrieving this attribute? For example, the following line returns an object of the System.DBNull type:
I've used the following object type:
Also, what versions of dotConnect for Oracle (speaking about the latest one, do you mean the Beta 6.0.10 build or the latest release 5.70.152 version?) and Oracle server are you using?
Code: Select all
object obj = MyOracleObject["number1"];
Code: Select all
CREATE OR REPLACE TYPE MY_OBJECT AS OBJECT (
ID NUMBER(38),
VALUE1 VARCHAR2(20),
NUMBER1 NUMBER(38)
)
-
- Posts: 9
- Joined: Wed 02 Apr 2008 13:35
The version I use is 5.70.152.0.
I'm using the index, just as you do:
In my case, the attribute of the oracle type is declared as FLOAT.
Also, this is an inherited attribute:
But it does not return System.DBNull and instead an InvalidCastException is thrown.
What about the second issue? Why does GetOracleValue() return 0.0?
I would expect an OracleNumber object with the IsNull property set to true.
Any ideas?
BTW: I still have the old CoreLab.Oracle assemblies installed on my machine, but I don't reference them in this project.
I'm using the index, just as you do:
Code: Select all
object obj = MyOracleObject["number1"];
Also, this is an inherited attribute:
Code: Select all
create or replace type MY_PARENT_TYPE as object
(
TestAttribute FLOAT
)
/
create or replace type MY_TYPE under MY_PARENT_TYPE
(
SecondAttribute DATE;
)
/
What about the second issue? Why does GetOracleValue() return 0.0?
I would expect an OracleNumber object with the IsNull property set to true.
Any ideas?
BTW: I still have the old CoreLab.Oracle assemblies installed on my machine, but I don't reference them in this project.
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
Thank you for your assistance, we've reproduced the issue in the case of inherited types. We will investigate it and inform you about the results.
As for the GetOracleValue method, in our environment it returns System.DBNull in the case of null at the server side. Could you please specify the version of the Oracle server you are using so that we are able to reproduce the issue?
The designed behaviour for GetOracleValue is to return either double or DBNull for FLOAT database fields. We do not plan to change this behaviour as this would affect the compatibility with prior versions.
Concerning the CoreLab assemblies, they should not influence the applications using dotConnect for Oracle.
As for the GetOracleValue method, in our environment it returns System.DBNull in the case of null at the server side. Could you please specify the version of the Oracle server you are using so that we are able to reproduce the issue?
The designed behaviour for GetOracleValue is to return either double or DBNull for FLOAT database fields. We do not plan to change this behaviour as this would affect the compatibility with prior versions.
Concerning the CoreLab assemblies, they should not influence the applications using dotConnect for Oracle.
-
- Posts: 9
- Joined: Wed 02 Apr 2008 13:35
Database Version
Hi,
my Database is 11.1.0.6 64 Bit Standard Edition One on Windows Server 2008 R2.
Regarding the GetOracleValue method: that's no problem. I was just pointing out what I would expect.
I'm no longer using the indexer in my project, instead I use GetOracleValue now. So, I don't rely on a patch. Anyway... good to hear you could reproduce the issue.
Thanks,
Thomas Hoekstra
my Database is 11.1.0.6 64 Bit Standard Edition One on Windows Server 2008 R2.
Regarding the GetOracleValue method: that's no problem. I was just pointing out what I would expect.
I'm no longer using the indexer in my project, instead I use GetOracleValue now. So, I don't rely on a patch. Anyway... good to hear you could reproduce the issue.
Thanks,
Thomas Hoekstra
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
Could you please specify the version of Oracle client you are using, and the way you are receiving OracleObject from the database? We couldn't reproduce the issue with GetOracleValue returning zero instead of DBNull.
Also, we've fixed the issue with attributes, the fix will be available in the nearest build.
Also, we've fixed the issue with attributes, the fix will be available in the nearest build.
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
We've released the 5.70.170 build of dotConnect for Oracle. It contains the fix for the issue with attributes of the inherited type. The build can be downloaded from
http://www.devart.com/dotconnect/oracle/download.html
(the trial version) or from Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/
The detailed information about the fixes and improvements implemented in dotConnect for Oracle 5.70.170 is available at
http://www.devart.com/forums/viewtopic.php?t=19068
http://www.devart.com/dotconnect/oracle/download.html
(the trial version) or from Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/
The detailed information about the fixes and improvements implemented in dotConnect for Oracle 5.70.170 is available at
http://www.devart.com/forums/viewtopic.php?t=19068