Question

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)

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

Was it helpful?

Solution

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 " //.....

The missing whitespace will make the SQL:

SELECT * FROM table1JOIN table2 ON ....

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top