First time poster, so please forgive any faux paus
I'm trying to add a record to the end of a table via C/ODBC. As far as I can see, there is no auto increment mechanism, so it looks like I'm going to have to determine the last primary key value, and do my insert with that value + 1.
'SELECT MAX(id)' gives me the result I need, but it consistently takes between 20 and 30 seconds to process the query - which is a bit of a problem. The table in question has around 27,000 rows.
'SELECT TOP n' and 'LIMIT' don't seem to be supported in C/ODBC.
So my question is: does anyone know of an alternative way to get the last row in a table, or determine the highest value of a field, hopefully a quick method than MAX(id)?
I'm running Navision 3.01
See MSDN for SQLGetInfo parameters and usage http://msdn.microsoft.com/en-us/library ... 81(v=vs.85).aspx
The DBMS name is also available from SQLGetInfo(handle, SQL_DBMS_NAME, ...) which returns "ACCESS" for MS Access & "SQLite" for SQLite. If you're using a driver which is giving incorrect keywords back you could additionally use the specific DBMS name to determine which type of syntax to use