stmt->close calls table->closeScan not close as earlier.
[csql.git] / src / sql / SelStatement.cxx
blob660ad06407413f9f8d0029d3be3557e20fe54893
1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #include "Statement.h"
18 SelStatement::SelStatement()
20 parsedData = NULL;
21 dbMgr = NULL;
22 table = NULL;
23 params = NULL;
24 paramValues = NULL;
25 totalParams = 0;
26 bindFields = NULL;
27 bindFieldValues = NULL;
28 totalFields = 0;
31 SelStatement::~SelStatement()
33 if (table) {
34 table->setCondition(NULL);
35 //if (dbMgr) dbMgr->closeTable(table);
36 table->close();
37 delete table;
39 if (totalParams) {
40 free(params);
41 params = NULL;
42 free(paramValues);
43 paramValues = NULL;
45 if (totalFields)
47 free(bindFields);
48 bindFields = NULL;
49 free(bindFieldValues);
50 bindFieldValues = NULL;
54 DbRetVal SelStatement::getParamFldInfo(int paramNo, FieldInfo *&info)
56 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
57 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
58 if (NULL == cValue)
60 printError(ErrSysFatal, "condition value is null. Should never happen");
61 return ErrSysFatal;
63 table->getFieldNameAlone(cValue->fName,info->fldName);
64 info->type = cValue->type;
65 info->length = cValue->length;
66 info->isNull = cValue->isNullable;
67 return OK;
69 DbRetVal SelStatement::execute(int &rowsAffected)
71 DbRetVal rv = OK;
72 //copy param values to binded buffer
73 ConditionValue *value;
74 for (int i = 0; i < totalParams; i ++)
76 value = (ConditionValue*) params[i];
77 if (paramValues[i] == NULL)
79 continue;
80 //printError(ErrBadCall, "param values not set");
81 //return ErrBadCall;
83 AllDataType::copyVal(value->value, paramValues[i], value->type, value->length);
85 rv = table->execute();
86 //table->printPlan(0);
87 return rv;
90 DbRetVal SelStatement::setParam(int paramNo, void *value)
92 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
93 if (NULL == value) return ErrBadArg;
94 paramValues[paramNo -1] = (char*) value;
95 return OK;
98 DbRetVal SelStatement::setShortParam(int paramNo, short value)
100 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
101 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
102 if (NULL == cValue)
104 printError(ErrSysFatal, "field value is null. Should never happen");
105 return ErrSysFatal;
107 *(short*)cValue->value = value;
108 return OK;
111 DbRetVal SelStatement::setIntParam(int paramNo, int value)
113 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
114 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
115 if (NULL == cValue)
117 printError(ErrSysFatal, "condition value is null. Should never happen");
118 return ErrSysFatal;
120 *(int*)cValue->value = value;
121 return OK;
123 DbRetVal SelStatement::setLongParam(int paramNo, long value)
125 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
126 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
127 if (NULL == cValue)
129 printError(ErrSysFatal, "condition value is null. Should never happen");
130 return ErrSysFatal;
132 *(long*)cValue->value = value;
133 return OK;
136 DbRetVal SelStatement::setLongLongParam(int paramNo, long long value)
138 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
139 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
140 if (NULL == cValue)
142 printError(ErrSysFatal, "condition value is null. Should never happen");
143 return ErrSysFatal;
145 *(long long*)cValue->value = value;
146 return OK;
148 DbRetVal SelStatement::setByteIntParam(int paramNo, ByteInt value)
150 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
151 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
152 if (NULL == cValue)
154 printError(ErrSysFatal, "condition value is null. Should never happen");
155 return ErrSysFatal;
157 *(ByteInt*)cValue->value = value;
158 return OK;
160 DbRetVal SelStatement::setFloatParam(int paramNo, float value)
162 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
163 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
164 if (NULL == cValue)
166 printError(ErrSysFatal, "condition value is null. Should never happen");
167 return ErrSysFatal;
169 *(float*)cValue->value = value;
170 return OK;
172 DbRetVal SelStatement::setDoubleParam(int paramNo, double value)
174 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
175 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
176 if (NULL == cValue)
178 printError(ErrSysFatal, "condition value is null. Should never happen");
179 return ErrSysFatal;
181 *(double*)cValue->value = value;
182 return OK;
184 DbRetVal SelStatement::setStringParam(int paramNo, char *value)
186 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
187 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
188 if (NULL == cValue)
190 printError(ErrSysFatal, "condition value is null. Should never happen");
191 return ErrSysFatal;
193 strcpy((char*)cValue->value, value);
194 return OK;
196 DbRetVal SelStatement::setDateParam(int paramNo, Date value)
198 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
199 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
200 if (NULL == cValue)
202 printError(ErrSysFatal, "condition value is null. Should never happen");
203 return ErrSysFatal;
205 *(Date*)cValue->value = value;
206 return OK;
208 DbRetVal SelStatement::setTimeParam(int paramNo, Time value)
210 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
211 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
212 if (NULL == cValue)
214 printError(ErrSysFatal, "condition value is null. Should never happen");
215 return ErrSysFatal;
217 *(Time*)cValue->value = value;
218 return OK;
220 DbRetVal SelStatement::setTimeStampParam(int paramNo, TimeStamp value)
222 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
223 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
224 if (NULL == cValue)
226 printError(ErrSysFatal, "condition value is null. Should never happen");
227 return ErrSysFatal;
229 *(TimeStamp*)cValue->value = value;
230 return OK;
233 DbRetVal SelStatement::setBinaryParam(int paramNo, void *value)
235 if (paramNo <=0 || paramNo > totalParams) return ErrBadArg;
236 ConditionValue *cValue = (ConditionValue*) params [paramNo-1];
237 if (NULL == cValue)
239 printError(ErrSysFatal, "condition value is null. Should never happen");
240 return ErrSysFatal;
242 AllDataType::convertToBinary(cValue->value,value,typeString,cValue->length);
243 return OK;
246 DbRetVal SelStatement::setBindField(int colNo, void *value)
248 if (colNo <=0) return ErrBadArg;
249 //TODO: check the upper limit
250 //if (colNo > table->getFieldNameList().size()) return ErrBadArg;
251 if (NULL == value) return ErrBadArg;
252 bindFieldValues[colNo -1] = (char*) value;
253 return OK;
255 DbRetVal SelStatement::openTables()
257 if (dbMgr == NULL) return ErrNoConnection;
258 JoinTableImpl *jHdl = NULL;
259 Table *tHdl = NULL, *prevHdl = NULL;
260 bool joinInvolved = false;
261 //check whether all the table exists
262 ListIterator titer = parsedData->getTableNameList().getIterator();
263 while (titer.hasElement())
265 TableName *t = (TableName*)titer.nextElement();
266 tHdl = dbMgr->openTable(t->tblName);
267 if ( NULL == tHdl )
269 printError(ErrNotExists,
270 "Unable to open the table:Table not exists");
271 return ErrNotExists;
273 if (NULL != prevHdl)
275 joinInvolved = true;
276 jHdl = new JoinTableImpl();
277 jHdl->setTable(prevHdl, tHdl);
278 prevHdl = jHdl;
279 continue;
281 prevHdl = tHdl;
283 if (joinInvolved) table = jHdl; else table = tHdl;
284 return OK;
286 DbRetVal SelStatement::resolve()
288 DbRetVal rv = openTables();
289 if (rv != OK) return rv;
290 //get the fieldname list and validate field names
291 ListIterator iter = parsedData->getFieldNameList().getIterator();
292 FieldName *name = NULL;
293 FieldInfo *fInfo = new FieldInfo();
294 List bindFldList;
295 AggTableImpl *aggTable = NULL;
296 while (iter.hasElement())
298 name = (FieldName*)iter.nextElement();
299 if (NULL == name)
301 dbMgr->closeTable(table);
302 table = NULL;
303 delete fInfo;
304 printError(ErrSysFatal, "Should never happen. Field Name list has NULL");
305 return ErrSysFatal;
307 bool isBindFld=false;
308 if ('*' == name->fldName[0] && name->aType == AGG_UNKNOWN)
310 rv = resolveStar();
311 if (rv != OK)
313 dbMgr->closeTable(table);
314 table = NULL;
315 delete fInfo;
316 return rv;
318 if (parsedData->getGroupFieldNameList().size()!= 0)
320 if (!aggTable)
321 aggTable = new AggTableImpl();
322 aggTable->setTable(table);
324 //as soon as it encounters *, it breaks the loop negleting other field names
325 //as they all are deleted during resolveStar method.
326 break;
327 }else {
328 if ('*' == name->fldName[0] && name->aType != AGG_COUNT) {return ErrSyntaxError;}
329 rv = table->getFieldInfo(name->fldName, fInfo);
330 if (ErrNotFound == rv || ErrNotExists == rv)
332 dbMgr->closeTable(table);
333 table = NULL;
334 delete fInfo;
335 printError(ErrSyntaxError, "Field %s does not exist in table",
336 name->fldName);
337 return ErrSyntaxError;
339 FieldValue *newVal = new FieldValue();
340 strcpy(newVal->fldName,name->fldName);
341 newVal->parsedString = NULL;
342 newVal->paramNo = 0;
343 newVal->type = fInfo->type;
344 newVal->length = fInfo->length;
345 newVal->isNullable = fInfo->isNull;
346 FieldName *bFldName=NULL;
347 ListIterator it = bindFldList.getIterator();
348 while (it.hasElement())
350 bFldName = (FieldName*)it.nextElement();
351 if(0==strcmp(bFldName->fldName,name->fldName))
353 newVal->value=table->getBindFldAddr(name->fldName);
354 newVal->isAllocVal=false;
355 isBindFld=true;
356 break;
359 if (!isBindFld) {
360 if(newVal->type == typeBinary)
361 newVal->value = AllDataType::alloc(fInfo->type,
362 2 * fInfo->length);
363 else newVal->value = AllDataType::alloc(fInfo->type,
364 fInfo->length);
365 newVal->isAllocVal=true;
367 if (name->aType ==AGG_UNKNOWN &&
368 parsedData->getGroupFieldNameList().size()== 0)
369 table->bindFld(name->fldName, newVal->value);
370 else {
371 if (!aggTable) {
372 aggTable = new AggTableImpl();
373 aggTable->setTable(table);
375 aggTable->bindFld(name->fldName, name->aType, newVal->value);
377 parsedData->insertFieldValue(newVal);
379 if (!isBindFld) bindFldList.append(name);
381 bindFldList.reset();
382 rv = setBindFieldAndValues();
383 if (rv != OK)
385 delete fInfo;
386 dbMgr->closeTable(table);
387 table = NULL;
388 return rv;
391 table->setCondition(parsedData->getCondition());
393 rv = resolveForCondition();
394 if (rv != OK)
396 delete fInfo;
397 //TODO::free memory allocated for params
398 table->setCondition(NULL);
399 dbMgr->closeTable(table);
400 table = NULL;
401 return rv;
403 rv = resolveGroupFld(aggTable);
404 if (rv != OK)
406 delete fInfo;
407 //TODO::free memory allocated for params
408 if (table)
410 table->setCondition(NULL);
411 dbMgr->closeTable(table);
413 table = NULL;
414 return rv;
416 delete fInfo;
417 return rv;
419 DbRetVal SelStatement::resolveGroupFld(AggTableImpl *aggTable)
421 if (!aggTable) return OK;
422 ListIterator giter = parsedData->getGroupFieldNameList().getIterator();
423 FieldName *name = NULL;
424 DbRetVal rv = OK;
425 FieldInfo *fInfo = new FieldInfo();
426 if (giter.hasElement())
428 name = (FieldName*)giter.nextElement();
429 rv = table->getFieldInfo(name->fldName, fInfo);
430 if (ErrNotFound == rv || ErrNotExists == rv)
432 dbMgr->closeTable(table);
433 table = NULL;
434 delete fInfo;
435 delete aggTable;
436 printError(ErrSyntaxError, "Field %s does not exist in table",
437 name->fldName);
438 return ErrSyntaxError;
440 FieldValue *newVal = new FieldValue();
441 strcpy(newVal->fldName,name->fldName);
442 newVal->parsedString = NULL;
443 newVal->paramNo = 0;
444 newVal->type = fInfo->type;
445 newVal->isNullable = fInfo->isNull;
446 newVal->length = fInfo->length;
447 if (newVal->type == typeBinary)
448 newVal->value = AllDataType::alloc(fInfo->type, 2 * fInfo->length);
449 else newVal->value = AllDataType::alloc(fInfo->type, fInfo->length);
450 newVal->isAllocVal=true;
451 parsedData->insertFieldValue(newVal);
452 aggTable->setGroup(name->fldName, newVal->value);
454 delete fInfo;
455 if (giter.hasElement())
457 table= aggTable;
458 printError(ErrSyntaxError, "Only one field allowed in group\n");
459 return ErrSyntaxError;
461 table = aggTable;
462 return OK;
464 DbRetVal SelStatement::resolveStar()
466 DbRetVal rv = OK;
467 parsedData->clearFieldNameList();
469 List fNameList = table->getFieldNameList();
470 ListIterator fNameIter = fNameList.getIterator();
471 FieldValue *newVal = NULL;
472 //fNameList.resetIter(); //do not remove this.
473 FieldInfo *fInfo = new FieldInfo();
474 for (int i = 0; i < fNameList.size() ; i++)
476 char *fName = ((Identifier*)(fNameIter.nextElement()))->name;
477 rv = table->getFieldInfo(fName, fInfo);
478 if (ErrNotFound == rv || ErrNotExists == rv)
480 delete fInfo;
481 fNameList.reset();
482 printError(ErrSysFatal, "Should never happen.");
483 return ErrSysFatal;
485 newVal = new FieldValue();
486 strcpy(newVal->fldName,fName);
487 newVal->parsedString = NULL;
488 newVal->paramNo = 0;
489 newVal->type = fInfo->type;
490 newVal->length = fInfo->length;
491 // for binary datatype input buffer size should be 2 times the length
492 if(newVal->type == typeBinary)
493 newVal->value = AllDataType::alloc(fInfo->type, 2 * fInfo->length);
494 else newVal->value = AllDataType::alloc(fInfo->type, fInfo->length);
495 newVal->isAllocVal=true;
496 parsedData->insertFieldValue(newVal);
497 parsedData->insertField(fName);
498 table->bindFld(fName, newVal->value);
500 fNameIter.reset();
501 while (fNameIter.hasElement())
502 delete (Identifier *) fNameIter.nextElement();
503 fNameList.reset();
504 delete fInfo;
505 return OK;
508 DbRetVal SelStatement::setBindFieldAndValues()
510 totalFields = parsedData->getFieldNameList().size();
511 bindFields = (FieldValue**) malloc ( totalFields * sizeof(FieldValue*));
512 bindFieldValues = (char**) malloc( totalFields * sizeof(char*));
513 memset(bindFields, 0, totalFields * sizeof(FieldValue*));
514 memset(bindFieldValues, 0, totalFields * sizeof(char*));
515 ListIterator valIter = parsedData->getFieldValueList().getIterator();
516 int colNo =0;
517 FieldValue *value = NULL;
518 valIter.reset();
519 while(valIter.hasElement())
521 value = (FieldValue*) valIter.nextElement();
522 if (value == NULL)
524 free(bindFields); bindFields = NULL;
525 free(bindFieldValues); bindFieldValues = NULL;
526 printError(ErrSysFatal, "Should never happen. value NULL after iteration");
527 return ErrSysFatal;
529 bindFields[colNo++ ] = value;
531 return OK;
535 DbRetVal SelStatement::resolveForCondition()
537 //get the fieldname list and validate field names
538 ListIterator iter = parsedData->getConditionValueList().getIterator();
540 ConditionValue *value;
541 FieldInfo *fInfo = new FieldInfo();
542 int paramPos =1;
543 DbRetVal rv = OK;
544 while (iter.hasElement())
546 value = (ConditionValue*) iter.nextElement();
547 if (NULL == value)
549 delete fInfo;
550 printError(ErrSysFatal, "Should never happen.");
551 return ErrSysFatal;
553 rv = table->getFieldInfo(value->fName, fInfo);
554 if (ErrNotFound == rv || ErrNotExists == rv)
556 delete fInfo;
557 printError(ErrSyntaxError, "Field %s does not exist in table",
558 value->fName);
559 return ErrSyntaxError;
561 value->type = fInfo->type;
562 value->length = fInfo->length;
563 value->isNullable = fInfo->isNull;
564 value->value = AllDataType::alloc(fInfo->type, fInfo->length);
565 //table->bindFld(name->fldName, value->value);
566 if (value->parsedString == NULL)
568 delete fInfo;
569 printError(ErrSyntaxError, "Condition value should not be NULL");
570 return ErrSyntaxError;
572 if (value->parsedString[0] == '?')
574 if(!value->opLike) // checks if 'LIKE' operator is used
575 value->paramNo = paramPos++;
577 if (!value->paramNo) {
578 // Here for binary dataType it is not strcpy'd bcos internally memcmp is done for predicates like f2 = 'abcd' where f2 is binary
579 AllDataType::strToValue(value->value, value->parsedString, fInfo->type, fInfo->length);
582 delete fInfo;
583 totalParams = paramPos -1;
584 if (0 == totalParams) return OK;
585 params = (void**) malloc ( totalParams * sizeof(FieldValue*));
586 paramValues = (char**) malloc( totalParams * sizeof(char*));
587 memset(params, 0, totalParams * sizeof(FieldValue*));
588 memset(paramValues, 0, totalParams * sizeof(char*));
589 iter.reset();
590 while(iter.hasElement())
592 value = (ConditionValue*) iter.nextElement();
593 if (value == NULL)
595 free(params); params = NULL;
596 free(paramValues); paramValues = NULL;
597 printError(ErrSysFatal, "Should never happen. value NULL after iteration");
598 return ErrSysFatal;
600 params[value->paramNo -1 ] = value;
602 return OK;
605 void* SelStatement::fetch()
607 void *tuple = table->fetch();
608 if (NULL == tuple) return NULL;
609 //copy values to binded buffer
610 FieldValue *value;
611 for (int i = 0; i < totalFields; i++)
613 value = bindFields[i];
614 if (bindFieldValues[i] == NULL)
616 printError(ErrBadCall, "Fields are not binded properly. Should never happen");
617 return NULL;
619 AllDataType::copyVal(bindFieldValues[i], value->value, value->type, value->length);
621 return tuple;
624 void* SelStatement::fetch(DbRetVal &rv)
626 void *tuple = table->fetch(rv);
627 if (NULL == tuple) return NULL;
628 //copy values to binded buffer
629 FieldValue *value;
630 for (int i = 0; i < totalFields; i++)
632 value = bindFields[i];
633 if (bindFieldValues[i] == NULL)
635 printError(ErrBadCall, "Fields are not binded properly. Should never happen %d", i);
636 return NULL;
638 AllDataType::copyVal(bindFieldValues[i], value->value, value->type, value->length);
640 return tuple;
643 DbRetVal SelStatement::close()
645 return table->closeScan();
648 DbRetVal SelStatement::freeScan()
650 if (table) return table->close();
651 else return OK;
654 void* SelStatement::getParamValuePtr( int pos )
656 ConditionValue *p = (ConditionValue*) params [pos-1];
657 return ( (void*) p->value );
660 char* SelStatement::getFieldName ( int pos )
662 //TODO::if not yet prepared return error
663 //TODO::check the upper limit for projpos
664 ListIterator iter = parsedData->getFieldNameList().getIterator();
665 int position =0;
666 while (iter.hasElement())
668 if (position == pos) {
669 FieldName *name = (FieldName*) iter.nextElement();
670 if (NULL == name)
672 printError(ErrSysFatal, "Should never happen. Field Name list has NULL");
673 return (char*) 0;
675 return name->fldName;
677 position++;
679 return (char*) 0;
682 DataType SelStatement::getFieldType( int pos )
684 FieldValue *v = bindFields[pos];
685 return ( (DataType) v->type );
688 int SelStatement::getFieldLength( int pos )
690 FieldValue *v = bindFields[pos];
691 return ( (int) v->type );
694 void* SelStatement::fetchAndPrint(bool SQL)
696 void *tuple = table->fetch();
697 if (NULL == tuple) return NULL;
698 FieldValue *value;
699 bool nullValueSet;
700 char stmt[128];
701 if (SQL) {
702 sprintf(stmt, "INSERT INTO %s VALUES(", table->getName());
703 printf("%s", stmt);
705 for (int i = 0; i < totalFields; i++)
707 value = bindFields[i];
708 nullValueSet = table->isFldNull(value->fldName);
709 if (nullValueSet)
710 if (SQL) {
711 if (i==0)
712 printf("NULL");
713 else
714 printf(", NULL");
716 else printf("NULL\t");
717 else {
718 if (SQL) {
719 switch(value->type)
721 case typeString:
722 case typeBinary:
723 case typeDate:
724 case typeTime:
725 case typeTimeStamp:
727 if (i==0)
728 printf(" '");
729 else
730 printf(", '");
731 break;
733 default:
735 if (i!=0)
736 printf(",");
740 AllDataType::printVal(value->value, value->type, value->length);
741 if (SQL) {
742 switch(value->type)
744 case typeString:
745 case typeBinary:
746 case typeDate:
747 case typeTime:
748 case typeTimeStamp:
749 printf("'");
751 } else printf("\t");
754 if (SQL) printf(");\n");
755 return tuple;
758 void* SelStatement::next()
760 return( table->fetch() );
764 void* SelStatement::getFieldValuePtr( int pos )
766 FieldValue *v = bindFields[pos];
767 return ( (void*) v->value );
770 int SelStatement::noOfProjFields()
772 return totalFields;
775 DbRetVal SelStatement::getProjFldInfo (int projpos, FieldInfo *&fInfo)
777 //TODO::if not yet prepared return error
778 //TODO::check the upper limit for projpos
779 //TODO::validate if projpos is less than size of the list
780 ListIterator iter = parsedData->getFieldNameList().getIterator();
781 FieldName *name = NULL;
782 DbRetVal rv = OK;
783 int position =0;
784 while (iter.hasElement())
786 name = (FieldName*)iter.nextElement();
787 if (NULL == name)
789 printError(ErrSysFatal, "Should never happen. Field Name list has NULL");
790 return ErrSysFatal;
792 if (position == (projpos-1)) break;
793 position++;
796 rv = table->getFieldInfo(name->fldName, fInfo);
797 if (OK == rv)
799 //get back the qualified name(tablename.fldname)
800 char qualName[IDENTIFIER_LENGTH];
801 strcpy(qualName, name->fldName);
802 switch(name->aType)
804 case AGG_COUNT:
805 sprintf(fInfo->fldName, "COUNT(%s)", qualName);
806 break;
807 case AGG_MIN:
808 sprintf(fInfo->fldName, "MIN(%s)", qualName);
809 break;
810 case AGG_MAX:
811 sprintf(fInfo->fldName, "MAX(%s)", qualName);
812 break;
813 case AGG_SUM:
814 sprintf(fInfo->fldName, "SUM(%s)", qualName);
815 break;
816 case AGG_AVG:
817 sprintf(fInfo->fldName, "AVG(%s)", qualName);
818 break;
819 default:
820 strcpy(fInfo->fldName, qualName);
821 break;
824 return rv;
826 int SelStatement::getFldPos(char *name)
828 return table->getFldPos(name);