int TDBPIVOT::ReadDB(PGLOBAL g) { int rc = RC_OK; bool newrow = FALSE; PCOL colp; if (FileStatus == 2) return RC_EF; if (FileStatus) for (colp = Columns; colp; colp = colp->GetNext()) if (colp->GetAmType() == TYPE_AM_SRC) ((PSRCCOL)colp)->SetColumn(); // New row, reset all function column values for (colp = Columns; colp; colp = colp->GetNext()) if (colp->GetAmType() == TYPE_AM_FNC) colp->GetValue()->Reset(); /*********************************************************************/ /* Now start the multi reading process. */ /*********************************************************************/ do { if (RowFlag != 1) { if ((rc = Tdbp->ReadDB(g)) != RC_OK) { if (FileStatus && rc == RC_EF) { // A prepared row remains to be sent FileStatus = 2; rc = RC_OK; } // endif FileStatus break; } // endif rc for (colp = Tdbp->GetColumns(); colp; colp = colp->GetNext()) colp->ReadColumn(g); for (colp = Columns; colp; colp = colp->GetNext()) if (colp->GetAmType() == TYPE_AM_SRC) if (FileStatus) { if (((PSRCCOL)colp)->CompareLast()) { newrow = (RowFlag) ? TRUE : FALSE; break; } // endif CompareLast } else ((PSRCCOL)colp)->SetColumn(); FileStatus = 1; } // endif RowFlag if (newrow) { RowFlag = 1; break; } else RowFlag = 2; // Look for the column having this header for (colp = Columns; colp; colp = colp->GetNext()) if (colp->GetAmType() == TYPE_AM_FNC) { if (((PFNCCOL)colp)->CompareColumn()) break; } // endif AmType if (!colp && !(colp = Dcolp)) { if (!Accept) { strcpy(g->Message, MSG(NO_MATCH_COL)); return RC_FX; } else continue; } // endif colp // Set the value of the matching column from the fonction value colp->GetValue()->SetValue_pval(Fcolp->GetValue()); } while (RowFlag == 2); N++; return rc; } // end of ReadDB