When the change is submitted?

EmjuEmju Member Posts: 11
Hello,

VarRecord.modify();
When the change is submitted?
a) a submit is implicitly called after the modify
b) when leaving the trigger
c) modify submit the transaction

Could you please explain these issues to me?
I found in online help: "When the system enters a C/AL codeunit, it automatically enables write transactions to be performed. When the system exits a C/AL code module, it automatically ends the write transaction by committing the updates made by the C/AL code."
I think that b) is the correct answer
Am I right?
--
Tom

Comments

  • PassHopePassHope Member Posts: 25
    I'm almost sure I read somewhere that modify submitted the change.
    I wrote a code in to try this.

    Customer.GET('45779977');
    Customer.Name := 'New Name';
    Customer.MODIFY;
    MESSAGE('New name is : %1', Customer.Name);
    

    The MESSAGE was first displayed, and after that the error message came, telling I was not allowed to change the customer database. This supports your theory.

    New code :

    Customer.GET('45779977');
    Customer.Name := 'New Name';
    Customer.MODIFY;
    Item.GET('1000');
    MESSAGE('New name is : %1', Customer.Name);
    

    With this example I first received the error message and not the other MESSAGE. So the modification will be submitted before the leaving the trigger or at least until next record command is being given. I changed the Item.GET command with Item.COUNT, and only the error message came. This supports my prevois theory.

    B must be wrong. When you use modify I believe it is not an transaction, but a change. I would go for A.

    I know if you use LOCKTABLE and not COMMIT, then the table is unlocked when it leaves the trigger.

    BTW I have only worked with C/AL code and Navision for 2 1/2 month, som I'm not a pro, so maybee some seniors knows this better!
  • EmjuEmju Member Posts: 11
    Thank you for your information.
    Colud you explain your answer to the question about transaction type?
    --
    Tom
  • PassHopePassHope Member Posts: 25
    I have copied this from the C/SIDE reference guide in TransactionType :

    When you use Navision Database Server, it maps to Snapshot and when you use SQL Server, it maps to Browse.
  • EmjuEmju Member Posts: 11
    The passage C/SIDE Ref. Guide concerns a Report option that maps to one of the basic options but does not explain if it guarantees a consistent snapshot of the data read within the transaction.

    However in the Transaction Type description in Snapshopt paragraph it is said that
    This is a read-only transaction. Modifications cannot occur within the transaction. All read operations are performed with SERIALIZABLE locking. Therefore, share-locks are placed and are maintained until the end of the transaction. This guarantees a consistent snapshot of the data read within the transaction.

    Therefore I think that the option should be set as Snapshot but not Browse.
    --
    Tom
Sign In or Register to comment.