One Star

tMSSQL_LastInsertID returning 0 after changing Select @@IDENTITY to SCOOE_IDENTITY


Im having an issue where tMSSQLLastInsertID object is returning a 0 after changing the code located here:


to the following:

log4jCodeGenerateUtil.logInfo(node,"info",cid + " - Query:'SELECT @@IDENTITY'");
java.sql.PreparedStatement pstmt_<%=cid %> = conn_<%=cid %>.prepareStatement("SELECT SCOPE_IDENTITY() as 'last_insert_id'");
int nb_line_<%=cid%> = 0;


I have a trigger on the table and that is why I need to change to Scope_Identity instead of using @@identity.  When I use @@identity it returns the incorect ID.  With the change I made above it returns 0, I have also tried just SCOPE_IDENTITY() without the as and it also returns 0.  I have also tried select SCOPE_IDENTITY() in the line above in blue still returns 0.

The ID field is a bigint that is auto incrementing.


Any help would be greatly appreciated

Tags (1)