Problem with a Temporary Table

sabzamsabzam Member Posts: 1,149
Hi, I am accessing a table and insert a copy of the extracted record into a temporary table. What is quite strange is that I excess again the same table but under a different name and post a copy of the record into the same temporary table and for some reason the temporary table is being cleared from all the records.

Has anyone got any idea why this may be happening?

Comments

  • SLF25SLF25 Member Posts: 37
    Can you elaborate on this?
  • ara3nara3n Member Posts: 9,256
    every variable of a temporary instance of a table has it's own instance and memory. They do not share records.

    If you do want to share the records. You you can make it an array of a temporary record variable.


    That way If you insert in MyRecord[1]. MyRecord[2] will read it.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • M._EleveldM._Eleveld Member Posts: 5
    I believe (could be that i'm reading it wrong) that there is just one temp table being used. And inserting records from table B into this temp table will make the previously inserted records of table A dissappear from the temp table.

    Not quite sure if this is the case though, would help if some code is posted.
  • sabzamsabzam Member Posts: 1,149
    Hi,

    the case is exactly as has been described by M. Eleveld . The only coding being used is

    BankLedgerEntry.Copy(BankAccount1);
    BankLedgerEntry.Insert;

    BankLedgerEntry.Copy(BankAccount2);
    BankLedgerEntry.Insert;

    The first part for table while the second for table b. BankLedgerEntry is a temporary table. I simply can't understand which the entries are automatically being deleted as soon as I insert the first line in table B. Could it be that there is a propery or something which I don't know about it?
  • SLF25SLF25 Member Posts: 37
    BankLedgerEntry.RESET should do the trick.
  • NaviDevNaviDev Member Posts: 365
    Why wont use the TRANSFERFIELDS command.

    Like
    TempRec.DELETEALL;
    TempRec.INIT;
    TempRec.TRANSFERFIELDS(Rec);
    TempRec.INSERT;
    
    Navision noob....
  • jlandeenjlandeen Member Posts: 524
    One problem with temporary records that I've seen is that the debugger does not cope with them very well. So the record may have been inserted into the table but you don't see it when you zoom in using the debugger. I'm assuming that BankAccount1 & 2 can be copied to BLE records.
    BankLedgerEntry.Copy(BankAccount1); 
    BankLedgerEntry.Insert; 
    
    BankLedgerEntry.Copy(BankAccount2); 
    BankLedgerEntry.Insert; 
    
    BankLedgerEntry.Reset;
    If not confirm('BLE Record Count: %1',true,BankLedgerEntry.count) then error(''); 
    

    Try something like this to see or use a form to display ALL of the records in the set.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • ayhan06ayhan06 Member Posts: 210
    this piece of code does not work as you expected.
    sabzam wrote:
    BankLedgerEntry.Copy(BankAccount1);
    BankLedgerEntry.Insert;

    insted of copy, use direct assignment of records.
    banaccount1.find('-');
    repeat
      BankLedgerEntry := BankAccount1;
      BankLedgerEntry.INSERT; 
    until bankaccount1.next=0
    
    try this.
  • kinekine Member Posts: 12,562
    Yes, the copy function is mainly used when you need to coppy the sorting order and filters. Not values. The assigning the record is better way how to transfer just values from one record to another (when tables are same).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • sabzamsabzam Member Posts: 1,149
    Hi Thanks alot for your support. The ':=' has worked perfectly. Apparently the filters where in some way distracting the temporary Table.
Sign In or Register to comment.