简体   繁体   中英

Getting ORA-00932: inconsistent datatypes error

I am getting following error when I am running my program in Windows 2008 R2 Enterprise, I do not get ant error when I run on Windows 10.

System.Data.OracleClient.OracleException: ORA-00932: inconsistent datatypes at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) at System.Data.OracleClient.OracleDataReader.ReadInternal() at System.Data.OracleClient.OracleDataReader.Read()....

My code is:

cmdExpressContainer.CommandText = "SELECT IU.ID EQ_NBR,IF.TIME_IN disch_time,IU.CATEGORY CAT,MV.TO_POS_NAME AS DISCHARGE_LOCATION " +
                                    "FROM INV_UNIT IU  " +
                                    "JOIN INV_UNIT_FCY_VISIT IF ON IF.UNIT_GKEY=IU.GKEY  " +
                                    "JOIN ARGO_CARRIER_VISIT CV ON CV.GKEY=IF. ACTUAL_OB_CV OR CV.GKEY=IF. ACTUAL_IB_CV  " +
                                    "JOIN inv_move_EVENT MV ON MV.UFV_GKEY=IF.GKEY  " +
                                    "JOIN VSL_VESSEL_VISIT_DETAILS  VVD ON VVD.VVD_GKEY=CV.CVCVD_GKEY  " +
                                    "JOIN VSL_VESSELS  VV ON VV.GKEY=VVD.VESSEL_GKEY  " +
                                    "WHERE CV.ID='" + tVoyageRef + "' AND MV.MOVE_KIND IN('DSCH') AND IU.CATEGORY='IMPRT'";



using (OracleDataReader drExpContainer = cmdExpressContainer.ExecuteReader())
{
    while (drExpContainer.Read())
    {
        //
    }
}

I do not understand why this is working in my PC (Windows 10) and gives error in other PC (Windows 2008 R2).

I am getting that error in this line:

drExpContainer.Read()

ORA-932 means that you tried to use some binary operation with incompatible arguments, say, asked to multiply date and character values. You should review these operations in your SQL statement and carefully check argument datatypes; maybe you should to avoid implicit datatype conversions and use explicit to_char, to_number etc.

When querying it sometimes happens that SQL statement works into one database session and fails into other. It happens because of data magic if these sessions uses different execution plans. Let's see simplified example:

SQL> create table t$(i integer, j varchar2(10 char));

Table created

SQL> insert into t$ values (1, 'abc');

1 row inserted

SQL> select * from t$ where i = 2 and to_number(j) = 8;

This statement is generally incorrect. It may works if Oracle will check 'i' condition before 'j' and it will fail if Oracle decide to check 'j' first. Which way would be used? It depends of execution plan while execution plan depends of optimizer mode and other settings and can be different in different sessions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM