INSERT error on MODIFY statement

Fred_CIT
Member Posts: 16
Consider the code below when executed on a SQL server
gRecSalesLine.INIT;
gRecSalesLine."Document Type" := gRecSalesLine."Document Type"::Quote;
gRecSalesLine."Document No." := 'XXXXXXXXXXXXX';
gRecSalesLine."Line No." := 20000;
MESSAGE('FIRST INSERT');
gRecSalesLine.INSERT;
MESSAGE('SECOND INSERT');
gRecSalesLine.INSERT;
MESSAGE('MODIFY');
gRecSalesLine.MODIFY;
When I execute this code (on SQL) I receive a error 'The Sales Line already exists' on the MODIFY statement and not as expected on the INSERT statement.
I get the impressions it has something to do with database caching, but could someone explain me the precise reason?
gRecSalesLine.INIT;
gRecSalesLine."Document Type" := gRecSalesLine."Document Type"::Quote;
gRecSalesLine."Document No." := 'XXXXXXXXXXXXX';
gRecSalesLine."Line No." := 20000;
MESSAGE('FIRST INSERT');
gRecSalesLine.INSERT;
MESSAGE('SECOND INSERT');
gRecSalesLine.INSERT;
MESSAGE('MODIFY');
gRecSalesLine.MODIFY;
When I execute this code (on SQL) I receive a error 'The Sales Line already exists' on the MODIFY statement and not as expected on the INSERT statement.
I get the impressions it has something to do with database caching, but could someone explain me the precise reason?
0
Comments
-
How do you know it's on the modify statement? did you use the debugger?
personally I would put the message after the statement. If the statement errors then I would not see the message.0 -
Both the debugger and the generated messages tell you the error occurs on the MODIFY statement. You may even put a load of extra code between the Insert and Modify statement; the result stays the same.
Just copy paste the code to a new codeunit and add a global variable 'gRecSalesLine' (Record 37). Run it on a SQL and see it for yourself.0 -
I don't have sql running here :oops:0
-
You're sure?
Which version do you use?
RegardsDo you make it right, it works too!0 -
I'm using NAV 5.0 SP1 and SQL 2005
Anyone can confirm this issue?0 -
Anyone can confirm this issue?
But it really wouldn't be an issue if the code is written correctly would it.?! :-k
Personally I would never write something like that anyway :whistle:0 -
This is happening in SP1 because of delayed inserts (new SP1 feature). The inserts to the database do not occur until the MODIFY is called. Try (for test only) putting a commit after each statement to force it to the DB. You will see the error message after the second insert.There are no bugs - only undocumented features.0
-
Oh, it's a new "Feature" you call it0
-
ok, 5.01.
I've tested with 4.03.
Your "phenomenon" is based on the "delay" insert (as bbrown said).
Check the release notes of 5.01.
RegardsDo you make it right, it works too!0 -
Thanks for the replies0
-
And I also blogged about the NAV 5.0SP1 bulk-insert possibility...
http://mibuso.com/blogs/kriki/2008/04/01/sql-changes-for-50sp1/
http://mibuso.com/blogs/kriki/2008/11/14/nav500sp1-bulk-insert-and-code-testing-on-sql/Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions