▲▲线程中用ADOQuery做聚组查询遇到ORA-00979 错误!
牧牛人软件 2005-07-13 09:10:19 =============================================
ORA-00979 not a GROUP BY expression
Cause: The GROUP BY clause does not contain all the expressions in the SELECT clause. SELECT expressions that are not included in a group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, must be listed in the GROUP BY clause.
Action: Include in the GROUP BY clause all SELECT expressions that are not group function arguments.
==============================================
我的问题有点复杂,请您耐心,谢谢!
同时符合以下3个条件,我的程序就会出现ORA-00979错误!
1.SQL有含有DATABASE LINK NAME。
因为我的客户端程序是通过服务器A,间接访问服务器B的(因为服务器B安全性要求较高),服务器A用DATABASE LINK连接服务器B。
2.SQL用聚组函数SUM(),含有GROUP BY clause 。
3.在线程中查询
或者 主程序中查询,而且ADOQuery是临时NEW的:TADOQuery *ADOQuery=new TADOQuery(NULL);
===================================================================
示意代码:
TADOQuery *ADOQuery=new TADOQuery(NULL);
ADOQuery->ConnectionString=MainForm->ADOConnectionStr;
String SqlString="Select unit, sum(num) from p_user@DBLINK_B group by unit";
//▲▲如果SqlString中没有sum() 或者没有 @DBLINK_B,返回结果正常。
ADOQuery->SQL->Add(SqlString);
ADOQuery->Open();
if(ADOQuery->Active){
ADOQuery->DisableControls();
while(!ADOQuery->Eof )
ShowMessage ( ADOQuery->FieldByName( "unit" )->AsString );
ADOQuery->Next();
}
=======================================
我需要有多线程查询,这个问题太棘手!!
您有好的建议吗?谢谢!!