You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have issues in above code
If an error returns from 'saveSpecialOrderV2' procedure, then we have to roll-back all changes, means 'saveAOrder' function inserted row must be roll-back and 'updateInventoryForNewOrder' update query also should be reverted. But when I run this code snippet it is not roll-backing. Is there any issue?
Also I am passing 'connection' to all functions, is it the right way. Will the functions uses same connection that we have begin transaction?
I have following code in Node.js with typescript
asyncstartAnOrderByVendorV2(orderInfo: any): Promise<Result>{letconnection=awaitpool().getConnection();try{awaitconnection.beginTransaction();constupdateInventoryResult=awaitthis.updateInventoryForNewOrder(connection,orderInfo.orderGuid,orderInfo.loggedInUserId,UpdateInventoryType.CANCEL_ORDER);if(updateInventoryResult.status!==ErrorCodes.SUCCESS){resultData.status=ErrorCodes.ERROR;awaitconnection.rollback();returnresultData;}constorderResult=awaitthis.saveAOrder(connection,orderInfo);constcustomCutResult=awaitthis.saveCustomCutItemsV2(connection,customCutInput);if(customCutResult.status!==ErrorCodes.SUCCESS){resultData.status=ErrorCodes.ERROR;awaitconnection.rollback();returnresultData;}awaitconnection.commit();}catch(error){awaitconnection.rollback();resultData.status=ErrorCodes.ERROR;}finally{connection.release();// Close the connection in the finally block}returnresultData;}asyncupdateInventoryForNewOrder(connection: any,orderGuid: string,loggedInUserId: number,type: number): Promise<Result>{constorderResult=awaitconnection.query(`CALL GetPickTicketItemsForInventoryCalc_sp(?,@p_ErrID);`,[orderGuid]);// Call Get Stored procedure// Call Update Stored Procedure}asyncsaveAOrder(connection: any,orderInfo: any): Promise<Result>{// Call Insert Stored procedure}asyncsaveCustomCutItemsV2(connection: any,customCutInput: any): Promise<Result>{// Call Insert Stored procedure}
The text was updated successfully, but these errors were encountered:
I have issues in above code
If an error returns from 'saveSpecialOrderV2' procedure, then we have to roll-back all changes, means 'saveAOrder' function inserted row must be roll-back and 'updateInventoryForNewOrder' update query also should be reverted. But when I run this code snippet it is not roll-backing. Is there any issue?
Also I am passing 'connection' to all functions, is it the right way. Will the functions uses same connection that we have begin transaction?
I have following code in Node.js with typescript
The text was updated successfully, but these errors were encountered: