bool TDBPIVOT::MakeViewColumns(PGLOBAL g) { if (Tdbp->IsView()) { // Tdbp is a view ColDB cannot be used PCOL colp, cp; PTDBMY tdbp; if (Tdbp->GetAmType() != TYPE_AM_MYSQL) { strcpy(g->Message, "View is not MySQL"); return true; } else tdbp = (PTDBMY)Tdbp; if (!Fncol && !(Fncol = tdbp->FindFieldColumn(Picol))) { strcpy(g->Message, MSG(NO_DEF_FNCCOL)); return true; } // endif Fncol if (!Picol && !(Picol = tdbp->FindFieldColumn(Fncol))) { strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); return true; } // endif Picol // Now it is time to allocate the pivot and function columns if (!(Fcolp = tdbp->MakeFieldColumn(g, Fncol))) return true; if (!(Xcolp = tdbp->MakeFieldColumn(g, Picol))) return true; // Check and initialize the subtable columns for (cp = Columns; cp; cp = cp->GetNext()) if (cp->GetAmType() == TYPE_AM_SRC) { if ((colp = tdbp->MakeFieldColumn(g, cp->GetName()))) { ((PSRCCOL)cp)->Colp = colp; ((PSRCCOL)cp)->To_Val = colp->GetValue(); cp->AddStatus(BUF_READ); // All is done here } else return true; } else if (cp->GetAmType() == TYPE_AM_FNC) if (((PFNCCOL)cp)->InitColumn(g)) return TRUE; } // endif isview return false; } // end of MakeViewColumns
bool TDBOCCUR::ViewColumnList(PGLOBAL g) { char *pn; int i; PCOL colp, cp; PTDBMY tdbp; if (!Tdbp->IsView()) return false; if (Tdbp->GetAmType() != TYPE_AM_MYSQL) { strcpy(g->Message, "View is not MySQL"); return true; } else tdbp = (PTDBMY)Tdbp; for (cp = Columns; cp; cp = cp->GetNext()) if (cp->GetAmType() == TYPE_AM_PRX) { if ((colp = tdbp->MakeFieldColumn(g, cp->GetName()))) { ((PPRXCOL)cp)->Colp = colp; ((PPRXCOL)cp)->To_Val = colp->GetValue(); } else return true; } // endif Type Col = (PCOL*)PlugSubAlloc(g, NULL, Mult * sizeof(PCOL)); for (i = 0, pn = Colist; i < Mult; i++, pn += (strlen(pn) + 1)) if (!(Col[i] = tdbp->MakeFieldColumn(g, pn))) { // Column not found in table sprintf(g->Message, MSG(COL_ISNOT_TABLE), pn, Tabname); return true; } // endif Col return false; } // end of ViewColumnList