开发者

Sybase error while fetching columns more then 255 characters

I'm having problems while fetching data from columns which have more than 255 characters

I got such an error message:

Open Client Message:

Message number: LAYER = (1) ORIGIN = (4) SEVERITY = (1) NUMBER = (132)

Message String: ct_fetch(): user api layer: internal common library error: The bind of result set item 3 resulted in truncation.

It fetches only the first 255 rows and truncates the rest.

I have tried to imply below lines before ct_connect but didn't work

CS_BOOL boolv = CS_TRUE;
CS_RETCODE  retcode2 = ct_capability ( *connection, CS_GET, CS_CAP_REQUEST,    CS_WIDETABLES, &boolv);

here are some part of the code , do you have any suggestion

for (i = 0; i < num_cols; i++) {
        /*
         ** Get the column description.  ct_describe() fills the
         ** datafmt parameter with a description of the column.
         */
        retcode = ct_describe(cmd, (i + 1), &datafmt[i]);
        if (retcode != CS_SUCCEED) {
            ex_error("ex_fetch_data: ct_describe()开发者_StackOverflow failed");
            break;
        }

        /*
         ** update the datafmt structure to indicate that we want the
         ** results in a null terminated character string.
         **
         ** First, update datafmt.maxlength to contain the maximum
         ** possible length of the column. To do this, call
         ** ex_display_len() to determine the number of bytes needed
         ** for the character string representation, given the
         ** datatype described above.  Add one for the null
         ** termination character.
         */
        datafmt[i].maxlength = ex_display_dlen(&datafmt[i]) + 1;

        /*
         ** Set datatype and format to tell bind we want things
         ** converted to null terminated strings
         */
        datafmt[i].datatype = CS_LONGCHAR_TYPE;
        datafmt[i].format = CS_FMT_NULLTERM;

        /*
         ** Allocate memory for the column string
         */
        coldata[i].value = (CS_CHAR *) malloc(datafmt[i].maxlength);
        if (coldata[i].value == NULL) {
            ex_error("ex_fetch_data: malloc() failed");
            retcode = CS_MEM_ERROR;
            break;
        }

        /*
         ** Now bind.
         */
        retcode = ct_bind(cmd, (i + 1), &datafmt[i], coldata[i].value,
                &coldata[i].valuelen, (CS_SMALLINT *) &coldata[i].indicator);
        if (retcode != CS_SUCCEED) {
            ex_error("ex_fetch_data: ct_bind() failed");
            break;
        }
    }


.............
.............
.............

    /*
     ** Fetch the rows.  Loop while ct_fetch() returns CS_SUCCEED or
     ** CS_ROW_FAIL
     */
    while (((retcode = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED,
            &rows_read)) == CS_SUCCEED) || (retcode == CS_ROW_FAIL)) {


Even we have faced problem when we are using Sybase with Uniface,but uniface sybase driver has got a option which will truncate the data and save in some other table but while fetching we have to fetch data from all the tables.


When using the native jconn*.jar drivers you have to set the "?CHARSET=iso_1" parameter on the JDBC driver to connect to a Sybase server with a default charset of Roman 8, otherwise you see this 255 characters truncation issue.

Could this be the problem you are experiencing?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜