On 20/03/08 14:31, Jaime Carrera wrote:
Hi Markus and Moritz,

Thanks for your suggestions; I tried another loop (the one from v.in.db) and gave the result that I needed. Below are my "experiments": The first db_fetch loop (exits after one interaction): I have to "cheat" to be able to get all the records from the database:

  while(1){
    if(db_fetch (&cursor, DB_NEXT, &more) != DB_OK)
      return(-1);
    nodeprop=db_get_value_as_double(dbvalue,ctype);
    printf("node prop= %.2f\n",nodeprop);
    count++;
    if(count<12699) /* use max(cat) value for this one, just testing*/
       more=0;
    if ( more) break;
  }

Now, using the loop as used in v.in.db I get what I need, without "cheating':

   while ( db_fetch (&cursor, DB_NEXT, &more ) == DB_OK && more ) {
     nodeprop=db_get_value_as_double(dbvalue,ctype);
     printf("node prop= %.2f\n",nodeprop);
   }

There are two differences: on the first loop more==1 immediately, and thus exits the loop; while on the second one the loop is exptecting more==1. Another difference is the != or == DB_OK part.

What I can gather from this, is that the first loop is more appropriate to queries done on a category basis, but not for fetching an entire table.

I don't really understand the first one. Why do you break if more==1 ? Instead of

if(count<12699) /* use max(cat) value for this one, just testing*/
     more=0;
if ( more) break;

Shouldn't this just be

if(!more) break;

?

Moritz
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to