从具有超过255个字符的列中提取数据时遇到问题
我收到了这样的错误消息:
Open Client Message:
消息号:LAYER =(1)ORIGIN =(4)SEVERITY =(1)NUMBER =(132)
消息字符串:ct_fetch():用户api层:内部公共库错误:结果集项3的绑定导致截断。
它仅获取前255行并截断其余行。
我试图在ct_connect之前暗示下面的行但是没有用
CS_BOOL boolv = CS_TRUE;
CS_RETCODE retcode2 = ct_capability ( *connection, CS_GET, CS_CAP_REQUEST, CS_WIDETABLES, &boolv);
这里是代码的一部分,你有什么建议
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() 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)) {
答案 0 :(得分:0)
即使我们在使用Sybase和Uniface时遇到问题,但是uniface sybase驱动程序有一个选项可以截断数据并保存在其他表中,但在获取时我们必须从所有表中获取数据。
答案 1 :(得分:0)
使用本机jconn * .jar驱动程序时,必须在JDBC驱动程序上设置“?CHARSET = iso_1”参数,以使用默认字符集Roman 8连接到Sybase服务器,否则会看到此255个字符的截断问题
这可能是您遇到的问题吗?