<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> <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);"> if (fd < 0) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> 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);"> res = -1;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> res = SQLGetData(stmt, 1, SQL_BINARY, empty, 0, &colsize);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> fdlen = colsize;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> if (option_verbose > 2)</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> ast_verbose(VERBOSE_PREFIX_3 "COLSIZE = %d", colsize); //PRINTING COLSIZE ON CLI</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> if (fd > -1) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> char tmp[1]="";</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> lseek(fd, fdlen - 1, SEEK_SET);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> if (write(fd, tmp, 1) != 1) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> close(fd);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> res = -1;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> if (fd > -1){<br> //Trying to fetch data in chunks<br style="color: rgb(51, 51, 153);"></span><span style="color: rgb(51, 51, 153);"> for (offset = 0; offset < colsize; offset += CHUNKSIZE) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> 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);"> 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);"> goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> } else {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> 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);"> munmap(fdm, CHUNKSIZE);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> 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);"> unlink(fullpath);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> goto free_res;</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> }</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> close(fd);</span><br style="color: rgb(51, 51, 153);"><span style="color: rgb(51, 51, 153);"> 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, 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>