char *TDBWMI::MakeWQL(PGLOBAL g) { char *colist, *wql/*, *pw = NULL*/; int len, ncol = 0; bool first = true, noloc = false; PCOL colp; // Normal WQL statement to retrieve results for (colp = Columns; colp; colp = colp->GetNext()) if (!colp->IsSpecial() && (colp->GetColUse(U_P | U_J_EXT) || noloc)) ncol++; if (ncol) { colist = (char*)PlugSubAlloc(g, NULL, (NAM_LEN + 4) * ncol); for (colp = Columns; colp; colp = colp->GetNext()) if (!colp->IsSpecial()) { if (colp->GetResultType() == TYPE_DATE) ((DTVAL*)colp->GetValue())->SetFormat(g, "YYYYMMDDhhmmss", 19); if (colp->GetColUse(U_P | U_J_EXT) || noloc) { if (first) { strcpy(colist, colp->GetName()); first = false; } else strcat(strcat(colist, ", "), colp->GetName()); } // endif ColUse } // endif Special } else { // ncol == 0 can occur for queries such that sql count(*) from... // for which we will count the rows from sql * from... colist = (char*)PlugSubAlloc(g, NULL, 2); strcpy(colist, "*"); } // endif ncol // Below 14 is length of 'select ' + length of ' from ' + 1 len = (strlen(colist) + strlen(Wclass) + 14); len += (To_CondFil ? strlen(To_CondFil->Body) + 7 : 0); wql = (char*)PlugSubAlloc(g, NULL, len); strcat(strcat(strcpy(wql, "SELECT "), colist), " FROM "); strcat(wql, Wclass); if (To_CondFil) strcat(strcat(wql, " WHERE "), To_CondFil->Body); return wql; } // end of MakeWQL