#1 2021-07-08 15:31:55

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Problems with triggers and TDDDMonitoredDaemonProcessRest

Hi everyone, I'm using the TDDDMonitoredDaemonProcessRest class to monitor some update states within the system. This monitoring takes place on a field changed via trigger directly in the database. The problem is that orm only recognizes the changes when I start the server, then all subsequent changes are not recognized by orm.
Is there any kind of refresh from TSQLRecord?
See the code excerpt below:

function TProductDaemonProcess.ExecuteRetrievePendingAndSetProcessing: boolean;
begin
   fPendingTask := (fDaemon as TSyncProdutoIntegraDaemon).RestClass.Create(
   fDaemon.Rest,'IdWooCommerce>0 and (SyncSupraWoo=? or SyncSupraWoo is null)',['N']);
  if fPendingTask.ID=0 then begin
    result := false; 
    exit;
  end;
end;

Offline

#2 2021-07-09 07:39:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,350
Website

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

I really don't understand what you mean.

Can you detail what "monitor some update stats within the system"?
(please use gist to post some code)

Offline

#3 2021-07-09 11:53:34

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

Hi, Ab

The TDDDMonitoredDaemonProcessRest class serves to monitor the state of some field in a table and perform an action on the value contained in this field, right?
When the change in the value of this field being monitored occurs via trigger directly in the database, this change is not seen by TSQLRecord.
This way, when this SyncSupraWoo field is receiving a value directly from a trigger in the database, fPendingTask is never created. Understood?

Offline

#4 2021-07-09 18:06:06

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

Has anyone ever experienced this?

Offline

#5 2021-07-09 18:49:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,350
Website

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

TDDDMonitoredDaemonProcessRest has nothing to do directly about "monitoring the state of some field in a table".

It is about running some background process, with start/stop and state abilities.

Offline

#6 2021-07-09 18:58:07

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

hi ab,
Maybe I expressed myself wrongly. When I say monitor I am referring to the ExecuteRetrievePendingAndSetProcessing method which is checking the value of a given field to return true or false. that's the concept of pendingtask isn't it? or am I mistaken?

Offline

#7 2021-07-09 20:27:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,350
Website

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

Your TProductDaemonProcess.ExecuteRetrievePendingAndSetProcessing returns false in the last then begin...end but leave result unset.
It should return true or false.

The global logic is in TDDDMonitoredDaemonProcess.Execute.

One example of use is TDDDEmailerDaemonProcess.

Offline

#8 2021-07-12 11:43:19

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

That's right Ab, in TDDDEmailerDaemonProcess who the method's True or False result is controlled according to the value of TSQLRecord's State field.

fPendingTask := (fDaemon as TDDDEmailerDaemon).RestClass.Create(
    fDaemon.Rest,'State=? order by RowID',[ord(esPending)]);

that's exactly what doesn't work in my case, when the value of this field is changed by a trigger in the Bank a some manual update.
TSQLRecord in my case doesn't recognize that the field value has changed, so the method never returns True.

Offline

#9 2021-07-12 12:36:11

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: Problems with triggers and TDDDMonitoredDaemonProcessRest

Hi Ab, I found out that the problem is related to my mounted where clause.
It does not work:
IdWooCommerce>0 and (SyncSupraWoo=? or SyncSupraWoo is null)

but it works:

SyncSupraWoo=? or SyncSupraWoo is null

I can't use clause and with or.

Offline

Board footer

Powered by FluxBB