Bug #12025 sum(a*b)
Submitted: 19 Jul 2005 4:24 Modified: 25 Aug 2005 7:12
Reporter: r py Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version: OS:Windows (win2000)
Assigned to: CPU Architecture:Any

[19 Jul 2005 4:24] r py
Description:
create table tableA
(
  ...
  fz double not null default a,
  ...
)

create table tableB
(
 ...
 xs double not null,
 ...
)

sql:
    select sum(a.Fz) from tableA a, tableB b where ....
successful...

sql: 
    select sum(b.Xs) from tableA a,tableB b where ...

successful...

sql:
    select sum(a.Fz*b.Xs) from tableA a,tableB b where ...

error:
Exception: System.IndexOutOfRangeException
Message: Could not find specified column in results
Source: MySql.Data
   at MySql.Data.MySqlClient.MySqlDataReader.GetOrdinal(String name)

How to repeat:
email

Suggested fix:
data type
[19 Jul 2005 7:25] Vasily Kishkin
Could you please write here example code how you get result value ? Because the message " Could not find specified column in results" means that name of column was writen wrong. Better way if you write here some simple test case.
[21 Jul 2005 7:08] r py
NHibernate + MySql + C# + Log4net

Error:

HQL: select sum(bz.Fz*1) from RG.JMGAJ.Jxkh.Entities.Kh k,RG.JMGAJ.Jxkh.Entities.Khbz bz where k.Khbz.Id=bz.Id and k.Khdx.Userid='170760' and year(k.Khdate)='2005' and month(k.Khdate)='7'
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Hql.QueryTranslator [] - SQL: select sum(khbz1_.Fz*1) as x0_0_ from jxkh_kh kh0_, jxkh_khbz khbz1_ where (kh0_.Khbzid=khbz1_.Id)and(kh0_.Khdxid='170760')and(year(kh0_.Khdate)='2005')and(month(kh0_.Khdate)='7')
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Hql.QueryTranslator [] - HQL: select sum(bz.Fz*1) from RG.JMGAJ.Jxkh.Entities.Kh k,RG.JMGAJ.Jxkh.Entities.Khbz bz where k.Khbz.Id=bz.Id and k.Khdx.Userid='170760' and year(k.Khdate)='2005' and month(k.Khdate)='7'
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Hql.QueryTranslator [] - SQL: select sum(khbz1_.Fz*1) as x0_0_ from jxkh_kh kh0_, jxkh_khbz khbz1_ where (kh0_.Khbzid=khbz1_.Id)and(kh0_.Khdxid='170760')and(year(kh0_.Khdate)='2005')and(month(kh0_.Khdate)='7')
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Impl.BatcherImpl [] - about to open: 0 open IDbCommands, 0 open DataReaders
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Impl.BatcherImpl [] - Building an IDbCommand object for the SqlString: select sum(khbz1_.Fz*1) as x0_0_ from jxkh_kh kh0_, jxkh_khbz khbz1_ where (kh0_.Khbzid=khbz1_.Id)and(kh0_.Khdxid='170760')and(year(kh0_.Khdate)='2005')and(month(kh0_.Khdate)='7')
2005-07-21 15:15:20,250 [2396] INFO  NHibernate.Loader.Loader [] - select sum(khbz1_.Fz*1) as x0_0_ from jxkh_kh kh0_, jxkh_khbz khbz1_ where (kh0_.Khbzid=khbz1_.Id)and(kh0_.Khdxid='170760')and(year(kh0_.Khdate)='2005')and(month(kh0_.Khdate)='7')
2005-07-21 15:15:20,250 [2396] INFO  NHibernate.Impl.BatcherImpl [] - Preparing select sum(khbz1_.Fz*1) as x0_0_ from jxkh_kh kh0_, jxkh_khbz khbz1_ where (kh0_.Khbzid=khbz1_.Id)and(kh0_.Khdxid='170760')and(year(kh0_.Khdate)='2005')and(month(kh0_.Khdate)='7')
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Loader.Loader [] - processing result set
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Loader.Loader [] - result row: 
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Type.NullableType [] - returning '-2' as column: x0_0_
2005-07-21 15:15:20,250 [2396] DEBUG NHibernate.Impl.BatcherImpl [] - done closing: 0 open IDbCommands, 0 open DataReaders
2005-07-21 15:15:20,250 [2396] ERROR NHibernate.ADOException [] - Could not execute query
Exception: System.IndexOutOfRangeException
Message: Could not find specified column in results
Source: MySql.Data
   at MySql.Data.MySqlClient.MySqlDataReader.GetOrdinal(String name)
   at NHibernate.Driver.NHybridDataReader.GetOrdinal(String name)
   at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
   at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
   at NHibernate.Hql.QueryTranslator.GetResultColumnOrRow(Object[] row, IDataReader rs, ISessionImplementor session)
   at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, IList hydratedObjects, Object optionalObject, Object optionalId, Key[] keys, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
   at NHibernate.Hql.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)
[25 Jul 2005 7:12] Vasily Kishkin
Could you please write how you call GetOriginal() ? For example I call the function in my test case:

Console.WriteLine(rs2.GetOrdinal("sum(a.Fz*b.Xs)").ToString());

I didn't got any error.
[25 Aug 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".