Hi,
Without using a wrapper, is there a simple way of accessing a query's
results using field/column names instead of index offsets?

For example, instead of:
strcpy(DeptCodeStructure[i-1].DeptName, result[i*ncols+1]);

Something more like:
strcpy(DeptCodeStructure[i-1].DeptName,
fieldname("DeptName",result,i,ncols);

How does everyone else handle this kind of thing?

Many thanks!
Dan

For context, below I've included my typical routine.

    sqlite3 *pDB = NULL; // database pointer
    FILE* fp = fopen("dept.sql","a+");
    sqlite3_open("dept.sql",&pDB);

    char* sql = "SELECT * FROM Dept;";
    char **result = 0;
    int nrows, ncols;
    if(pDB != NULL){
        sqlite3_get_table(pDB,sql,&result,&nrows,&ncols,NULL);
        for(i = 1; i <= nrowss;i++){
                strcpy(DeptCodeStructure[i-1].DeptName, result[i*ncols+1]);
                DeptCodeStructure[i-1].RateCodeToUse  = atoi(result[i*ncols+2]);
        }
        sqlite3_free_table(result);
    }
    sqlite3_close(pDB);
    fclose(fp);



-- 
View this message in context: 
http://www.nabble.com/Possible-to-use-field-names-instead-of-index-offsets-in-queries--tp17461475p17461475.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to