Powerbuilder - Datawindow 更新后 SQLNRows 为 0

发布于 2024-07-11 00:27:18 字数 194 浏览 4 评论 0原文

我第一次在 DataWindow 上调用 Update 时,它返回 1(成功),而 SQLCA.SQLNRows 为 1。当我在同一屏幕上执行第二次更新而未关闭它时之间,Update 返回 1,SQLCA.SQLNRows 为 0。有什么建议说明为什么会发生这种情况吗?

The first time I call Update on my DataWindow it returns 1 (success) and SQLCA.SQLNRows is 1. When I do a second update on the same screen without closing it in between, Update returns 1 and SQLCA.SQLNRows is 0. Any suggestions why this is happening?

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

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

发布评论

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

评论(3

甜柠檬 2024-07-18 00:27:19

你的问题似乎涉及到一些事情。

首先,正如 John Paul 提到的,即使没有更新行,Update() 也会返回 1。 “什么也不做”没有具体的返回值。

其次,正如帮助文件中提到的,SQLNRows 的值与 DBMS 相关,因此在不知道所涉及的 DBMS 的情况下很难对其中填写的值进行评论。 然而,无论如何,由于 DataWindow 发出一系列仅针对一行的 INSERT、UPDATE 和 DELETE,如果填充此值,我不希望它会超过一个,无论有多少 SQL 语句数据窗口问题。 最后发出的 SQL 语句影响的行数应始终为 1。

如果您尝试查找受 DataWindow Update() 影响的行数,请在 Update() 之前检查 ModifiedCount() + DeletedCount() 的值。

祝你好运,

特里。

Your question seems to hit a couple of things.

Firstly, as John Paul mentions, Update() will return 1 even if there are no rows updated. There is no specific return value for "nothing to be done."

Secondly, as mentioned in the help file, the value for SQLNRows is DBMS-dependent, so it's hard to comment on the value being filled in there without knowing the DBMS involved. However, regardless of that, since the DataWindow issues a series of INSERTs, UPDATEs and DELETEs that are targeted at only one row, if this value is populated I wouldn't expect it would ever be more than one, no matter how many SQL statements the DataWindow issues. The number of rows affected for the last SQL statement issued should always be one.

If you're trying to find the number of rows affected by a DataWindow Update(), before the Update(), check the value of ModifiedCount() + DeletedCount().

Good luck,

Terry.

遮了一弯 2024-07-18 00:27:19

我已经很久没有使用PB了,但是.Update()的返回值不只是数据库成功执行命令(即UPDATE)的指示符吗? 如果这是正确的,那么成功时它将返回 1,即使行值实际上没有更改。 SqlNRows 是更改行数的实际指标。

It's been a long time since I've used PB, but isn't the .Update()'s return value simply an indicator of the command (i.e. UPDATE) being successfully performed by the DB? If this is correct then it'll return 1, when successful, even if row values are not actually changing. SqlNRows is the actual indicator of the number of changed rows.

夏末的微笑 2024-07-18 00:27:19

更新的答案:
您可以在 UpdateEnd 事件中获取 Update 的结果。 在这种情况下,您将拥有 rowsinserted、rowsupdatedrowsdeleted

原答案:
如果您使用 PFC,了解正在发生的情况的一个好方法是使用 SQL Spy 服务。 在非 PFC 应用程序中,您可以在 DataWindow 的 sqlpreview 事件中放置一条类似 beep(1) 的无操作行,在该行上设置断点,然后使用调试器来观察发生了什么。 您还可以使用 SQL 语句跟踪工具或数据库跟踪工具,如连接到数据库一书中的连接故障排除中所述。

Updated answer:
You can get the results of the Update in the UpdateEnd event. In that event you have rowsinserted, rowsupdated, and rowsdeleted.

Original answer:
A good way to tell what's going on if you're using PFC is to use the SQL Spy service. In a non-PFC app, you could put a do-nothing line like beep(1) in the DataWindow's sqlpreview event, set a breakpoint on that line, and use the debugger to watch what's going on. You could also use the SQL statement trace facility or the Database Trace tool as described in Troubleshooting Your Connection in the Connecting to Your Database book.

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