/ OcrColumns: constructs the result blocks containing all the columns */ of the object table that will be retrieved by GetData commands. */ /
| 80 | /* of the object table that will be retrieved by GetData commands. */ |
| 81 | /************************************************************************/ |
| 82 | bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col, |
| 83 | const char *ocr, const char *rank) |
| 84 | { |
| 85 | char *pn, *colist; |
| 86 | int i, k, m, n = 0, c = 0, j = qrp->Nblin; |
| 87 | bool rk, b = false; |
| 88 | PCOLRES crp; |
| 89 | |
| 90 | if (!col || !*col) { |
| 91 | strcpy(g->Message, "Missing colist"); |
| 92 | return true; |
| 93 | } // endif col |
| 94 | |
| 95 | // Prepare the column list |
| 96 | colist = PlugDup(g, col); |
| 97 | m = PrepareColist(colist); |
| 98 | |
| 99 | if ((rk = (rank && *rank))) { |
| 100 | if (m == 1) { |
| 101 | strcpy(g->Message, "Cannot handle one column colist and rank"); |
| 102 | return true; |
| 103 | } // endif m |
| 104 | |
| 105 | for (k = 0, pn = colist; k < m; k++, pn += (strlen(pn) + 1)) |
| 106 | n = MY_MAX(n, (signed)strlen(pn)); |
| 107 | |
| 108 | } // endif k |
| 109 | |
| 110 | // Default occur column name is the 1st colist column name |
| 111 | if (!ocr || !*ocr) |
| 112 | ocr = colist; |
| 113 | |
| 114 | /**********************************************************************/ |
| 115 | /* Replace the columns of the colist by the rank and occur columns. */ |
| 116 | /**********************************************************************/ |
| 117 | for (i = 0; i < qrp->Nblin; i++) { |
| 118 | for (k = 0, pn = colist; k < m; k++, pn += (strlen(pn) + 1)) |
| 119 | if (!stricmp(pn, qrp->Colresp->Kdata->GetCharValue(i))) |
| 120 | break; |
| 121 | |
| 122 | if (k < m) { |
| 123 | // This column belongs to colist |
| 124 | if (rk) { |
| 125 | // Place the rank column here |
| 126 | for (crp = qrp->Colresp; crp; crp = crp->Next) |
| 127 | switch (crp->Fld) { |
| 128 | case FLD_NAME: crp->Kdata->SetValue((char*)rank, i); break; |
| 129 | case FLD_TYPE: crp->Kdata->SetValue(TYPE_STRING, i); break; |
| 130 | case FLD_PREC: crp->Kdata->SetValue(n, i); break; |
| 131 | case FLD_SCALE: crp->Kdata->SetValue(0, i); break; |
| 132 | case FLD_NULL: crp->Kdata->SetValue(0, i); break; |
| 133 | case FLD_REM: crp->Kdata->Reset(i); break; |
| 134 | default: ; // Ignored by CONNECT |
| 135 | } // endswich Fld |
| 136 | |
| 137 | rk = false; |
| 138 | } else if (!b) { |
| 139 | // First remaining listed column, will be the occur column |
no test coverage detected