Пример #1
0
/*
 *  d e s c r i b e
 *
 *  describe columns of a table
 */
static void describe()
{
    if (!connected) {
        log("not connected!");
        return;
    } // if
    IString table = input.word(2);
    if (table=="") {
        log("missing table name!");
        return;
    } // if
    static KSqlCursor *csr;
    mainLink->getCursor(&csr);
    csr->parse("SELECT * FROM "+table+" WHERE ROWNUM<1");
    csr->execute();
    int cols = csr->selectColumnCount();
    int pcnt = 0;
    for (int col = 0; col < cols; col++) {
        ostrstream* out = new ostrstream();
        *out << setiosflags(ios::left) << setw(20) << setfill('.')
             << csr->selectColumnName(col)
             << setiosflags(0) << setw(0)  << setfill(' ')
             << ": " << csr->selectColumnDescription(col);
        char* ss = out->str();
        ss[out->pcount()] = 0;
        log(ss);
        delete ss;
        delete out;
        if (pausechk(pcnt)) break;
    } // for
} // describe