Lock Table & Job Queue

Hi All,

I have a job (Job1) that runs every minute in a Job Queue which posts journal entries. There is another job (Job2) that runs at the end of the day which locks the ledger table. When that happens Job Queue for Job1 crashes and the Job Queue Status gets updated to Error.

I'd like Job1 to run only if it the ledger table is not locked by another process. LOCKTABLE does not have return value for me to use a guarded IF. Try Function does not accept LOCKTABLE. Can someone recommend a workaround?

Appreciate any help.

Thanks!

Answers

  • ShaiHuludShaiHulud Member Posts: 228
    If you assign both Job Queue Entries to the same Job Queue Category, then they will not execute at the same time and you won't need to worry about one locking records required by the other.
  • ktwoonektwoone Member Posts: 4
    Thank you for replying @ShaiHulud. Unfortunately, that is not an option. I need a way to identify whether the specific table is locked. And if Yes, then don't execute my job.
  • air_wolfair_wolf Member Posts: 13
    ktwoone wrote: »
    Thank you for replying @ShaiHulud. Unfortunately, that is not an option. I need a way to identify whether the specific table is locked. And if Yes, then don't execute my job.

    You can implement a retry mechanism for the jobs and use it only on the job you want. Otherwise you will have to use a SQL query from within NAV to check it the table is locked and act based on the results. There are various SQL queries to do so, being a classic you can use an ADO connection and good luck :smile:

    But to be honest, @ShaiHulud 's solution is the easiest and the results are the same: job1 won't be executed unless job2 has finished.
Sign In or Register to comment.