Here's what I'm doing to get a list of column names as a first step in my "add column" routine. I see that limit 1 isn't limiting the output to the first row ie the column names... like it did when I used SQLitening. Is there a better way to do this? Any advice much appreciated.
int Append_column(char* col_nm, char* tbl_nm ){ //tbl comes last cos might be optional int max_lines = 5, max_length = 150, i=0, j; char** ln; ln = (char**)malloc(sizeof(char) * max_lines * max_length); //WOW...I had to do an explict case her // ln[0] = Join_pChars( 3, "SELECT * from ", tbl_nm , " LIMIT 1" ); ////do query char** results = NULL; int rows=0, columns=0; res = sqlite3_get_table(handle, ln[0], &results, &rows, &columns, &err); if (res){ fprintf(stderr, "SQL error: %s\n", err); sqlite3_free(err); return 1; } //test this gets the colnames for you tick ////display query result //limit 1 is giving the col names AND the 1st row that I don't want //for (int rowCtr = 0; rowCtr <= rows; ++rowCtr){ //this is giving me just the col names int rowCtr=0; for (int colCtr = 0; colCtr < columns; ++colCtr){ int cellPosition = (rowCtr * columns) + colCtr; printf( "%s\t", results[cellPosition] ); } printf( "\n"); //} return 0; } return 0; } _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users