gpt4 book ai didi

database - 获取超过 255 个字符的列时出现 Sybase 错误

转载 作者:搜寻专家 更新时间:2023-10-30 21:37:36 25 4
gpt4 key购买 nike

我在从超过 255 个字符的列中获取数据时遇到问题

我收到这样一条错误信息:

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.

它只获取前 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)) {

最佳答案

即使我们在将 Sybase 与 Uniface 一起使用时也遇到过问题,但是 uniface sybase 驱动程序有一个选项可以截断数据并保存在其他表中,但是在获取数据时我们必须从所有表中获取数据。

关于database - 获取超过 255 个字符的列时出现 Sybase 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2227442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com