Informix Dynamic Server 上的文本更新与文本插入

发布于 2024-09-08 17:24:20 字数 801 浏览 4 评论 0原文

我维护一个使用 ESQL 样式(Informix API)调用编写的第 3 方 Informix 驱动程序。我正在研究一个错误,对于文本字段,插入工作正常,而更新失败。单步执行代码,我发现我们正在检查 sqlda 结构来告诉我们是否以及如何绑定,并且在调用 sqli_describe_statement 后,sqlda.sqld 变量包含 2,即绑定参数的正确数量此插入调用,参数似乎设置正确,而在更新情况下,返回的数字为 0,没有参数信息(对于以下中的一个参数,它应该为 1:“UPDATE TESTTAB SET COLNAME = ? WHERE OTHERCOLNAME = 1”)。

使用 sqlda 信息,我们正确地设置了 INSERT 所需的定位器结构,但我们无法进行更新,因为该信息不存在。如果我在调试器中伪造它并运行更新的设置定位器代码,它会更新得很好。

该语句看起来肯定是正确的,并且 INSERT 和 UPDATE 绑定使用相同的变量。而且sqli_prep更新没有问题。对于描述,sqsla.code 返回不同的非负数 4 和 6,代表所描述的不同类型的语句,如记录的那样(即不是错误代码),因此那里没有明显的问题。

  1. 在此之前我是否应该检查代码中的其他内容可能会导致这种奇怪的行为(除了对不同查询的特殊情况处理之外 - 没有任何内容)

  2. 我是否在这里遗漏了一些关于如何在 TEXT 字段上进行 UPDATE 的基本内容,例如您必须创建一个定位器对象,找到该行,然后用脚后跟敲击三下,然后说“没有像 IBM 这样的地方吗?”

到目前为止,Google Fu 在文档中几乎没有出现,但如果您知道指明方向的文档或示例,那也很酷。

I maintain a 3rd party Informix driver that's written with ESQL-style (Informix API) calls. I'm working on a bug where, for TEXT fields, INSERTs work fine and UPDATEs fail. Stepping through the code, what I've found is that we're checking our sqlda structure to tell us whether and how to bind, and after the call to sqli_describe_statement, the sqlda.sqld variable contains 2, the correct number of bound parameters for this insert call, and the parameters appear to be set up correctly whereas in the update case, the number returned is 0, with no parameter information (it should be 1, for the one param in: "UPDATE TESTTAB SET COLNAME = ? WHERE OTHERCOLNAME = 1 ").

Using the sqlda information, we correctly set up the required locator structure for the INSERT, but we can't for the update because the information isn't there. If I fake it out in the debugger and run the set-up-the-locator code for the update, it updates fine.

The statement certainly appears correct, and the same variable is being used for the INSERT as the UPDATE bind. Moreover sqli_prep has no problem with the update. For the describe, sqsla.code returns different non-negative numbers 4 and 6, representing the different types of statements being described, as documeneted (i.e., not an error code), so there's no obvious problem there.

  1. Is there something else I should be checking in the code ahead of this that might cause this weird behavior (other than special case handling for the different queries -- nothing there)

  2. Am I missing something fundamental here about how one does UPDATEs on TEXT fields, such as you have to create a locator object, find the row, and click your heels together three times and say "There's no place like IBM?"

So far Google Fu has turned up little in the documentation, but if you know of docs or samples that point the way, that's cool too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

护你周全 2024-09-15 17:24:20

这是 Informix 行为的模糊领域之一。 DESCRIBE 的行为应该描述输出参数(它是 DESCRIBE OUTPUT stmt INTO ... 的简写);要描述输入参数,您可以使用DESCRIBE INPUT stmt INTO ...代替。

然而,由于各种原因,可以追溯到时间的黎明(好吧,1985 年),INSERT 语句获得了特殊情况豁免,并且简单的 DESCRIBE 描述了其输入参数 - 与 UPDATE 或 DELETE (或者,这些天,合并)。

因此,您的代码可能是在 DESCRIBE INPUT 和 DESCRIBE OUTPUT 变得可行之前编写的(大约 2000±3 年)。原则上,使用定向 DESCRIBE 语句应该可以解决该问题。可能需要设置 ONCONFIG 参数来获得此行为。

我记得我很感激这个功能的到来,但我也记得我在想“该死,我有一段时间不能使用它——直到没有它的旧版本全部退役”。我认为现在基本上已经发生了 - 特别是 IDS 7.31 现在已经过时,IDS 9.x 版本也确实如此,因此所有可用的 IDS 版本都支持该功能。 OnLine 5.20 - 少数利益 - 仍然不会也永远不会支持它。因此,我需要回顾一下如何更新我的程序(例如 SQLCMD)来利用这一点。那里的代码包括我所说的“vignettes”;它们是完整的小程序,说明如何使用 BYTE 和 TEXT blob。例如,您可能会发现 UPDBLOB 或 APPBLOB 有用。

This is one of the murky areas of Informix behaviour. The behaviour of DESCRIBE is supposed to describe output parameters (it is a shorthand for DESCRIBE OUTPUT stmt INTO ...); to describe the input parameters, you would use DESCRIBE INPUT stmt INTO ... instead.

However, for various reasons extending back to the dawn of time (well, 1985, anyway), the INSERT statement got a special case exemption and plain DESCRIBE described its input parameters - unlike UPDATE or DELETE (or, these days, MERGE).

So, your code was probably written before DESCRIBE INPUT and DESCRIBE OUTPUT became feasible (that was circa 2000±3 years). In principle, using the directed DESCRIBE statements should fix the issue. There may be an ONCONFIG parameter to be set to get this behaviour.

I remember being grateful that the feature arrived, but also I remember thinking "Damn, I'm not going to be able to use that for a while - until the old versions without it are all retired". I think that has basically happened now - IDS 7.31 in particular is now obsolete, and so indeed are the IDS 9.x versions, so all available versions of IDS support the feature. OnLine 5.20 - a minority interest - still doesn't and won't ever support it. So, I need to review how to update my programs such as SQLCMD to exploit this. The code there includes what I call 'vignettes'; they're complete little programs that illustrate how to work with BYTE and TEXT blobs. You might find UPDBLOB or APPBLOB, for example, of some use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文