We have table called Student with trigger is configured for that, while inserting any row in Student table. Trigger will fire 1 update and 2 insert statements to other tables.
Now we are trying to fetch auto generated ID of Student while inserting. It seems like jdbc resultset is pointing the first update statement (no row to update), because stmt.updateCount() is 0
and while calling stmt.getGeneratedKey()
is throwing exception of com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before any results can be obtained.
But the student row is inserted into table.
If I disable trigger, I can able to get the Generated ID as expected. Any Idea to get the generated ID of main table while trigger is happening ?
Thanks.