My Rails app is connected to a remote DB2 database, and when migrating I'm stumbling into this error:
== DropLegacyProject: migrating ========================================
rake aborted!
An error has occurred, this and all later migrations canceled:
RuntimeError: Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token "LIMIT" was found following "". Expected tokens may include: "FETCH FIRST <n> ROWS ONLY". SQLSTATE=42601 SQLCODE=-104: SELECT projects.* FROM projects WHERE projects.id < 17 LIMIT 1
How can I fix this?
DB2 does not support the LIMIT x keyword.
As the error message says, the proper way to do this would to use FETCH FIRST x ROWS ONLY instead.
As bhamby suggested, DB2 does not support the LIMIT x keyword... by default.
But starting with DB2 v9.7.2, support for LIMIT x can be enabled via the DB2_COMPATIBILITY_VECTOR registry variable:
db2set DB2_COMPATIBILITY_VECTOR=MYS
db2stop
db2start
...and it works!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With