Hi all,
1. Do some NAV code that inserts some data
2. Call a stored sql procedure with automation that should have access to the data from 1.
There should be NO commit between 1 and 2 because when a error occurs it should roll back the hole thing.
Is it possible to access uncommitted data in an sql procedure?
SQL Server 2008, NAV 2009 R2 Classic Client
greetings
0
Answers
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
@ara3n
- i dond't really know what you mean by "bulk insert"; how can i check if thats the case?; in my concreate example here, NAV is posting a sales shipment
- how can i tell my sql procedure to do that? i tried around with "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED" but with no success
@Mark
- you mean CREATE PROCEDURE [dbo].[CoolProcedureName] @param1 varchar(20) WITH NOLOCK AS [...] ? That brings a compile error "unknown option". Otherwise i don't know where to put that "hint"
1. Make some changes in NAV
2. Make some changes in SQL
Here, everything would get rolled back regardless for where the error happens. But now consider this.
1. Make some changes in NAV
2. Make some changes in SQL
3. More changes in NAV
If an error occurs in step 3, only the changes in NAV get rolled back. The SQL changes will be committed.
Well, i broke the whole thing down to a small insert in nav and select in sql example, and there it works when i use "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED".
So not a general problem. However in my real life scenario it doesn't work. Anyone an idea wich parameters could influence that behaviour?
@Edit: Found a solution. A modify/get/find in NAV from that record i want to select in SQL made it work. Makes no sense to me, as there are no changes to that rec in NAV after an insert, that happens before, but well, it does the job.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Is this always enabled or is it controllable?
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
IF INSERT THEN ;
...this will also not bulk insert. Of course if you need it to error if the insert fails then you could do...
IF NOT INSERT THEN ERROR(InsertFailedText);