子查询返回空结果集的PreparedStatement
我有一个查询,当我在 SQL Developer 中运行它时工作正常,但当作为准备好的语句运行时返回一个空结果集。我不确定我的查询格式是否不正确,或者是否是其他内容(我将完全留给另一个问题)。
这是我的查询。我已经剥离了一些内容,以便捕获它的格式,而不是业务逻辑。该表具有三列:类型、键和值。
SELECT a.key id, a.value name
FROM
(SELECT * FROM sometable WHERE type='A') a,
(SELECT * FROM sometable WHERE type='B') b,
(SELECT * FROM sometable WHERE type='C') c,
(SELECT * FROM sometable WHERE type='D') d
WHERE a.value = b.key
AND a.value = c.key
AND a.value = d.key
本质上,应该在准备好的语句中正确执行吗?
I've got a query that works fine when I run it in SQL Developer, but returns an empty result set when run as a prepared statement. I'm not sure if my query is formatted incorrectly, or if it's something else (which I'll leave for another question entirely).
So here is my query. I've stripped stuff out in order to capture the format of it, and not the business logic. The table has three columns: type, key, and value.
SELECT a.key id, a.value name
FROM
(SELECT * FROM sometable WHERE type='A') a,
(SELECT * FROM sometable WHERE type='B') b,
(SELECT * FROM sometable WHERE type='C') c,
(SELECT * FROM sometable WHERE type='D') d
WHERE a.value = b.key
AND a.value = c.key
AND a.value = d.key
Essentially, should this execute correctly in a prepared statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您看到任何错误吗?
查询可以作为 Statement< 运行/a> 因为它是静态 SQL。
Are you seeing any errors?
The query as is can be run as a Statement since it is a static SQL.