<html><head><style type='text/css'>p { margin: 0; }</style><style type='text/css'>body { font-family: 'Times New Roman'; font-size: 12pt; color: #000000}</style></head><body>I am trying to write a customized app using C that would fetch voice file from SQL Server 2000 using ODBC and FREETDS.<br><br>Currently I am only able to fetch first 63 KB chunk from the DB, and not able to fetch the rest of the file, below is the code that i am using to do so,<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 51, 153);">fd = open(fullpath, O_RDWR | O_CREAT | O_TRUNC, 0770);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (fd &lt; 0) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ast_log(LOG_WARNING, "Failed to write '%s': %s\n", fullpath, strerror(errno));</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res = -1;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res = SQLGetData(stmt, 1, SQL_BINARY, empty, 0, &amp;colsize);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fdlen = colsize;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (option_verbose &gt; 2)</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ast_verbose(VERBOSE_PREFIX_3 "COLSIZE&nbsp; =&nbsp; %d", colsize); &nbsp;&nbsp;  //PRINTING COLSIZE ON CLI</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (fd &gt; -1) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char tmp[1]="";</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lseek(fd, fdlen - 1, SEEK_SET);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (write(fd, tmp, 1) != 1) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; close(fd);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res = -1;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (fd &gt; -1){<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  //Trying to fetch data in chunks<br style="color: rgb(51, 51, 153);"></span><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (offset = 0; offset &lt; colsize; offset += CHUNKSIZE) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ((fdm = mmap(NULL, CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == MAP_FAILED) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ast_log(LOG_WARNING, "Could not mmap the output file: %s (%d)\n", strerror(errno), errno);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, CHUNKSIZE, NULL);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; munmap(fdm, CHUNKSIZE);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ((res != SQL_SUCCESS) &amp;&amp; (res != SQL_SUCCESS_WITH_INFO)) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unlink(fullpath);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; close(fd);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SQLFreeHandle(SQL_HANDLE_STMT, stmt);<br><br><span style="color: rgb(0, 0, 0);">The value of colsize printed on CLI is</span> <span style="color: rgb(0, 0, 0);">64512,&nbsp; Is there some limitation somewhere in FREETDS or ODBC. <br><br>Can anyone please help me to get this fixed?</span><br></span><br>Regards,<br>Sanjay Rajdev<br></body></html>