AQL calculated fields throwing errors

  • KM01513595
  • 14-Apr-2015
  • 16-Apr-2015

Summary

When an AQL calculated field is added to a list, an error message is displayed

Error

When an AQL calculated field is added to a list, an error message pops up:

2015/03/31 11:42:44.985 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@P1'. SQLSTate: 37000
2015/03/31 11:42:44.988 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@P2'. SQLSTate: 37000
2015/03/31 11:42:44.991 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'. SQLSTate: 37000
2015/03/31 11:42:44.979 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'AND'. SQLSTate: 37000
2015/03/31 11:42:44.996 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'WHEN'. SQLSTate: 37000
2015/03/31 11:42:44.999 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@P15'. SQLSTate: 37000
2015/03/31 11:42:45.001 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'. SQLSTate: 37000
2015/03/31 11:42:45.005 2 1 [Thrd#:5456](-2006) ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. SQLSTate: 37000

Fix

In the Asset Manager Windows client, go to Administration -> Database options and set the following two options to Yes:

ConstAsTextForGet

ConsAsTextForSelect

Also, make sure that thse two options are not set in the amdb.ini file

If the DBMS is Microsoft SQL Server, you must use the SQL Server native client as your ODBC driver.

This is also documented in "Chapter 13: Calculated fields" of the AM 9.50 Advanced Use manual