Java/IBSQL中的SQL Firebird实现 [英] SQL Firebird implementation in java/ IBSQL

查看:108
本文介绍了Java/IBSQL中的SQL Firebird实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此尝试将SQL代码放入我的Java应用程序中:

so tried to put that SQL code into my java-aplication:

    SELECT DISTINCT
  StRzImRo.Rohstoff, StRo.Bezeichnung,
CAST (SUM(BwLsImAt.Lieferungen * StRzImRo.Menge * StAt.PROD__REZEPTURGEWICHT / Coalesce(StRz.PARM__BEZUGSGROESSE,1))  AS NUMERIC (9,3)) Rohstoffverbrauch_Gesamt FROM BwLsImAt       

JOIN StAt ON (StAt.IntRowId = BwLsImAt.Artikel)
JOIN StRz ON (StRz.IntRowId = StAt.PROD__REZEPTUR)
JOIN StRzImRo ON (StRzImRo.Master = StRz.IntRowId)
JOIN StRo ON (StRzImRo.Rohstoff = StRo.IntRowId)
WHERE StAt.IntRowId > 0
 GROUP BY  StRzImRo.Rohstoff, StRo.Bezeichnung
-- GROUP BY  StRzImRo.Rohstoff, StRzImRo.Menge, StAt.PROD__REZEPTURGEWICHT, Coalesce(StRz.PARM__BEZUGSGROESSE,1)

该代码是完全功能性的,并已在IBSQL中进行了测试,但无法在我的Java应用程序中运行. 我的应用程序可以与其他代码一起正常使用.我收到此错误:

The code is fully funcional and tested in IBSQL but not working in my java-application. My app does work properly with other code. I get this error:

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 266
ON

如果有人可以帮助我解决这个问题,我将非常高兴.谢谢! 附注:对不起,我的语言不好,但我不是母语人士

I would be very happy if someone could help me with this problem. Thanks! P.S.: Sorry for my bad language, but i´m not a native speaker

推荐答案

该错误表明查询中的意外位置有ON,而且查询本身看起来还不错,我想这是问题所在您在Java应用程序中构造查询的方式.您的查询中可能缺少一些空格.

The error suggests there is an ON in an unexpected place in your query, and as the query itself looks fine, my guess is the problem is with the way you construct the query in your Java application. There might be some whitespace missing in your query.

我的猜测是你有类似的东西

My guess is that you have something like

query = "SELECT * " +
        "FROM table1" +
        "JOIN table2 ON " //.....

缺少空格将生成SQL:

The missing whitespace will make the SQL:

SELECT * FROM table1JOIN table2 ON ....

对于解析器,这是完全有效的,直到遇到ON令牌(该令牌触发错误)为止.例如,解析器将其标识为SELECT,其中*(所有)列均来自table1JOIN,且别名为table2.在解析期间,服务器不会检查表是否确实存在,因此它不会超越table1JOIN不存在的事实.解析成功完成后进行检查.

For the parser, this is perfectly valid until it encounters the ON token, which triggers the error. Eg the parser identifies it is a SELECT with * (all) columns from table1JOIN with alias table2. During parsing the server doesn't check if the table actually exists, so it doesn't trip over the fact that table1JOIN doesn't exist. That is checked after parsing is successfully completed.

这篇关于Java/IBSQL中的SQL Firebird实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆