One Star

tMSSQL_LastInsertID returning 0 after changing Select @@IDENTITY to SCOOE_IDENTITY

Hello,

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

\Talend\Talend\Studio\plugins\org.talend.designer.components.localprovider_6.5.1.20180116_1512\components\tMSSqlLastInsertId\tMSSqlLastInsertId_begin.javajet

to the following:

<%
log4jCodeGenerateUtil.useExistConnection(node);
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