使用 mozIStorageStatement 对象的executeAsync 的 SELECT 中的零结果行为,
我使用mozIStorageStatement对象的executeAsync函数运行SQL SELECT语句,问题是,当语句没有得到结果时,回调的handlerresult函数不会运行。这是正常行为还是我有错误?如果这是正常行为,那么我如何编写在结果为零的情况下运行的代码?
I run a SQL SELECT statement using executeAsync function of mozIStorageStatement object, the thing is, when the statement get no results, the handleresult function of the callback doesn't run. Is this a normal behaviour or do I have a bug? If it is a normal behaviour, then how do I write a code that will run in the case we have zero results?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是正常行为。仅当结果可用时才会调用
handleResult
方法,而绝不会(当查询返回空集时)。您可以在handleCompletion
方法中处理这种情况,无论查询是否返回任何行,该方法都始终执行。下面是一个用于演示的一次性示例:
aReason
参数可以具有以下值:REASON_FINISHED = 0
该语句已正常完成执行。REASON_CANCELED = 1
该语句因被取消而停止执行。REASON_ERROR = 2
该语句停止执行,因为发生错误。
进一步阅读:
This is normal behavior. The
handleResult
method is called only when results are available, which is never (when a query returns the empty set). You can handle this case in thehandleCompletion
method, which always executes, whether or not the query returns any rows.Here's a throwaway example to demonstrate:
The
aReason
parameter can have the following values:REASON_FINISHED = 0
The statement has finished executing normally.REASON_CANCELED = 1
The statement stopped executing because it was canceled.REASON_ERROR = 2
The statement stopped executing because anerror occurred.
Further reading: