NetTalk Central

Author Topic: Closing files clears the current record.  (Read 3257 times)

Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
Closing files clears the current record.
« on: October 06, 2021, 03:54:58 PM »
Clarion 11.1
NT 12.26
SQL Server 2014 Standard

I suspect that this may be at the root of many of the problems that are on my production server. This only becomes active after my production server has been running for a while. It doesn't occur on a fresh restart, or on my development server. The file record is cleared after a file is closed. To test this I created some simple code:
Code: [Select]
      dbgView('Before Close: ' & Inv:ItemID)
      dbgView('Result: ' & p_web.CloseFile(InvMaster))
      dbgView('Close Error:  ' & Error())
      dbgView('After Close: ' & Inv:ItemID)

The results on my development server and after a fresh restart:
[40340] [BackOffice] Before Close: 154
[40340] [BackOffice] Result: 0
[40340] [BackOffice] Close Error:  Entry Not Found
[40340] [BackOffice] After Close: 154

After my production server has been running:
[42892] [BackOffice] Before Close: 154
[42892] [BackOffice] Result: 0
[42892] [BackOffice] Close Error:  Entry Not Found
[42892] [BackOffice] After Close: 0

I feel like nettalk frequently assumes the record is still valid after a close, and I have no idea what might be clearing it.
Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Closing files clears the current record.
« Reply #1 on: October 06, 2021, 10:08:52 PM »
Hi Matthew,

It's "good form" to treat a record as "undefined" after the table has been closed, but as you note it is mostly ok to use records after they are closed (or before they are open). Except for Blobs and Memos - you can never touch those if the table is closed.

That said it is unusual to see a record buffer cleared by a class to CLOSE, and I would recommend digging a little deeper there. For example, you are calling p_web.CloseFile (which may contain embed code) so it might be handy to repeat the test using a simple CLOSE statement instead. (Either way, the result of that would be helpful in determining a direction to go.)

If there are specific calls to p_web.closeFile that you feel are messing up your code, let me know and I can investigate whether they are in the best place at the moment.

Cheers
Bruce

Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
Re: Closing files clears the current record.
« Reply #2 on: October 13, 2021, 02:52:34 PM »
I added a few more tests as I can only run them every so often.
Code: [Select]
        dbgView('Before Close: ' & Inv:Description)
      dbgView('Result: ' & p_web.CloseFile(InvMaster))
      dbgView('Close Error:  ' & Error())
      dbgView('After Close: ' & Inv:Description)
  dbgView('RelationManager')
  Relate:InvMaster.Open()
  Access:InvMaster.Fetch(Inv:PK_Master, p_web.gsv('ItemSave'))
  dbgView('Before Close: ' & Inv:Description)
  dbgView('Result: ' & Relate:InvMaster.Close())
  dbgView('Close Error:  ' & Error())
  dbgView('After Close: ' & Inv:Description)
  dbgView('File Manager')
  Access:InvMaster.Open()
  Inv:ItemID = p_web.gsv('ItemSave')
  Access:InvMaster.Fetch(Inv:PK_Master)
  dbgView('Before Close: ' & Inv:Description)
  dbgView('Result: ' & Access:InvMaster.Close())
  dbgView('Close Error:  ' & Error())
  dbgView('After Close: ' & Inv:Description)
  dbgView('Direct')
  Open(InvMaster)
  Inv:ItemID = p_web.gsv('ItemSave')
  Get(InvMaster, Inv:PK_Master)
  dbgView('Before Close: ' & Inv:Description)
  Close(InvMaster)
  dbgView('Close Error:  ' & Error())
  dbgView('After Close: ' & Inv:Description)

The results on my development server and after a fresh restart:
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Result: 0
[48968] [BackOffice] Close Error:  Entry Not Found
[48968] [BackOffice] After Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] RelationManager
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Result: 0
[48968] [BackOffice] Close Error:  Entry Not Found
[48968] [BackOffice] After Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] File Manager
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Result: 0
[48968] [BackOffice] Close Error: 
[48968] [BackOffice] After Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Direct
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Close Error: 
[48968] [BackOffice] After Close: Canadian Club 750ml

After my production server has been running:
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Result: 0
[48968] [BackOffice] Close Error:  Entry Not Found
[48968] [BackOffice] After Close:                                                                                                     
[48968] [BackOffice] RelationManager
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Result: 0
[48968] [BackOffice] Close Error:  Entry Not Found
[48968] [BackOffice] After Close:                                                                                                     
[48968] [BackOffice] File Manager
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Result: 0
[48968] [BackOffice] Close Error: 
[48968] [BackOffice] After Close:                                                                                                     
[48968] [BackOffice] Direct
[48968] [BackOffice] Before Close: Canadian Club 750ml                                                                                 
[48968] [BackOffice] Close Error: 
[48968] [BackOffice] After Close: Canadian Club 750ml

So FileManager is somehow changing behaviour while the program is running. I've look at the code and can't figure out what is doing this. I can put more diagnostics in to try and see if anything in filemanager has changed.

As far as specific location. Using a lookup browse closes the file before the call to AfterLookup. This is the case both for typing in the value, as well as using the lookup.
Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template