Re: Rows truncated at 176 chars when using CT-Lib interface

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
2009/4/29 Alejandro Guerrieri <[email protected]>:
> Frediano,
> Thanks for replying.
>
> I've just solved the issue. The problem was with the CS_DATAFMT structure
> member not being a pointer. I've replaced by:
>

Mmm.... quite strange... I think that real problem is ct_bind, on
first mail you have

ct_bind(conn->command, i+1, &data[i].format, &data[i].data,
&data[i].size, &data[i].ind);

while on second

ct_bind(conn->command, i+1, data[i].format, data[i].data,
&data[i].size, &data[i].ind);

you have changed data[i].format cause you used a pointer but
data[i].data change is the real fix.

freddy77

> struct data_s {
>
> CS_CHAR *data;
>
> CS_DATAFMT *format;
>
> CS_INT size;
>
> CS_SMALLINT ind;
>
> };
>
> struct data_s *data;
>
> And fixed the references on the code:
>
> data[i].format = malloc(sizeof(CS_DATAFMT));
>
> memset(data[i].format, 0, sizeof(CS_DATAFMT));
>
> if (ct_describe(conn->command, i+1, data[i].format) != CS_SUCCEED) {
>
> error(0, "Error fetching column description");
>
> free(data);
>
> return -1;
>
> }
>
> data[i].format->maxlength++;
>
> data[i].data = malloc(data[i].format->maxlength);
>
> data[i].format->datatype = CS_CHAR_TYPE;
>
> data[i].format->format = CS_FMT_NULLTERM;
>
> ct_bind(conn->command, i+1, data[i].format, data[i].data,
>
> &data[i].size, &data[i].ind);
>
> And that was it :)
>
> Regarding the select, it's a simple command:
>
> ct_command(conn->command, CS_LANG_CMD,
>
> "SELECT col1, col2, col3 FROM table",
>
> CS_NULLTERM, CS_UNUSED);
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.