gpt4 book ai didi

perl - Sybase::CTlib 的 ct_results() 和 ct_cmd_drop() 错误

转载 作者:行者123 更新时间:2023-12-02 22:56:24 25 4
gpt4 key购买 nike

我正在使用Sybase::CTlib查询 Sybase 服务器。但是,当我执行以下命令时:

while( $dbr->ct_results($restype) == CS_SUCCEED ) {
if( $restype == CS_CMD_FAIL ) {
warn "Update Check Failed...";
next;
}
next unless $dbr->ct_fetchable($restype);
$ts = $dbr->ct_fetch;
}

我的查询仅返回一个值。这就是为什么我要读取一个变量。

我收到错误:

Open Client Message:
Message number: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (163)
Message String: ct_results(): user api layer: external error: This routine cannot be called until all fetchable results have been completely processed.

Open Client Message:
Message number: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (159)
Message String: ct_cmd_drop(): user api layer: external error: This routine can be called only if the command structure is idle.

出了什么问题?

最佳答案

即使您的 SQL 返回一行,您也不能仅调用 ct_fetch 一次(正如您的代码所做的那样)。您必须循环调用它直到 false。

brian d foy's approach似乎是最简洁的解决方案(1 while (my @data = $dbh->ct_fetch); 所以我不会费心提供替代方案。我将提供的是显示代码失败原因的文档.

此行为记录在 ct_fetch 的 SyBooks 文档中:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.sdk_12.5.1.ctref/html/ctref/X65123.htm

If an application does not cancel a result set, it must completely process the result set by calling ct_fetch as long as ct_fetch continues to indicate that rows are available.

The simplest way to do this is in a loop that terminates when ct_fetch fails to return either CS_SUCCEED or CS_ROW_FAIL. After the loop terminates, an application can use a switch-type statement against ct_fetch’s final return code to find out what caused the termination.

If a result set contains zero rows, an application’s first ct_fetch call will return CS_END_DATA.

Note: An application must call ct_fetch in a loop even if a result set contains only a single row. An application must call ct_fetch until it fails to return either CS_SUCCEED or CS_ROW_FAIL.

我对原因的未经明确的猜测是,CTLib 中内部有一些“结果集已完成”标志设置为 false,并且直到 ct_fetch 发现不再有行存在时,它才会重新设置为 true。结果集(基本上就是 brian d foy 所说的); CTLib 代码的其余部分检查该标志,并在该标志为 false 时输出错误 163。

如果不查看实际的 CTLib 源代码,我无法 100% 确认这一点,我无法在文档中找到确切的原因

关于perl - Sybase::CTlib 的 ct_results() 和 ct_cmd_drop() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4012496/

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