Hi Markus and Moritz,<br><br>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":<br>The first db_fetch loop (exits after one interaction): I have to "cheat" to be able to get all the records from the database:<br><br>&nbsp; while(1){<br>&nbsp;&nbsp;&nbsp; if(db_fetch (&amp;cursor, DB_NEXT, &amp;more) != DB_OK)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(-1);<br>&nbsp;&nbsp;&nbsp; nodeprop=db_get_value_as_double(dbvalue,ctype);<br>&nbsp;&nbsp;&nbsp; printf("node prop= %.2f\n",nodeprop);<br>&nbsp;&nbsp;&nbsp; count++;<br>&nbsp;&nbsp;&nbsp; if(count&lt;12699) /* use max(cat) value for this one, just testing*/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; more=0;<br>&nbsp;&nbsp;&nbsp; if ( more) break;<br>&nbsp; }<br><br>Now, using the loop as used in v.in.db I get what I need, without "cheating':<br><br>&nbsp;&nbsp; while ( db_fetch (&amp;cursor, DB_NEXT, &amp;more ) == DB_OK &amp;&amp; more )
 {<br>&nbsp;&nbsp;&nbsp;&nbsp; nodeprop=db_get_value_as_double(dbvalue,ctype);<br>&nbsp;&nbsp;&nbsp;&nbsp; printf("node prop= %.2f\n",nodeprop);<br>&nbsp;&nbsp; }<br><br>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.<br><br>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. <br><br><br>Cheers,<br>Jaime<br><br><br><br><b><i>Moritz Lennert &lt;moritz.lennert@ulb.ac.be&gt;</i></b> escribió:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> On 20/03/08 00:19, Jaime Carrera wrote:<br>&gt; Hi list,<br>&gt; <br>&gt; My apologies if this question fits better in the developers list.<br>&gt; I'm trying to understand how db_fetch works and why am getting a strange <br>&gt;
 error.<br>&gt; After a query is executed and db_open_select_cursor is used, db_fetch is <br>&gt; used to fetch the data of the resultant query. AFAIK, db_fetch(&amp;cursor, <br>&gt; DB_NEXT, &amp;more) fetches the data on a row by row basis; is this correct? <br><br>Yes.<br><br>&gt; My problem is that everything works fine on my program except the <br>&gt; db_fetch loop, as the loop breaks after the first iteration (although my <br>&gt; table has 3000 rows).<br>&gt; Can someone help me to figure out why the loop breaks?<br><br>Is your cursor correct ? Are you checking for DB_OK ? What is the status <br>of more ? You defininetely have to check for the former and possibly for <br>the latter (as in some of the examples Markus sent, i.e. v.in.db/main.c.)<br><br>In general, it would be helpful to send your code to understand what is <br>happening.<br><br>Moritz<br></blockquote><br><p>&#32;






      <hr size=1><br><font face="Verdana" size="-2">¡Capacidad ilimitada de almacenamiento en tu correo!<br>No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:<br>
http://correo.espanol.yahoo.com/</font>