Strange situation with my ODBC code ( called from a C library ). Basically, I have the following sequence of events:
- Create insert statement ( just a string )
- Call SQLPrepare with that insert statement string
- Bind the various parameters ( column values ), using SQLBindParameter
- Call SQLExecute to insert the row ( this works, by the way, as I can see the row in the MySQL DB )
Create "select last_insert_id()" statement string
NOTE: if in SQL Server mode, we would create a "select @@identity" statement
Bind column using SQLBindCol - this is where I get the "Invalid descriptor index" error
NOTE: if in SQL Server mode, this works fine, with no error
Call SQLExecDirect to get the last insert id - this never happens because of SQLBindCol error
Does the standard MySQL ODBC connector require something special in this situation? Does anyone have an ODBC example of this type of "insert" then "get last insert id" behavior? Maybe I need to call "SQLPrepare" before step 6 ( where I bind the column )? Another way to ask this: Should there be an SQLPrepare call for each SQLExecute or SQLExecDirect call?
I know it works directly in SQL, so the problem is my C ODBC code.
Thanks.