Skip to main content

Hi Freaks

UnifAce gave us a few function to check the database modus of various "things" like

  • $formdbmod
  • $instancedbmod
  • $occdbmod
  • $fielddbmod

But I need a $entdbmod() which will check if any occurrence of a entity is modified.
Okay, I can code a loop over all occurrence and whith the first $occdbmod() I leave the loop with true.
But i'm worried that it might take a while. :-)
Any other ideas?
Ingo


$entdbmod()



------------------------------
Ingo Stiller
Aareon Deutschland GmbH
------------------------------

Hi Freaks

UnifAce gave us a few function to check the database modus of various "things" like

  • $formdbmod
  • $instancedbmod
  • $occdbmod
  • $fielddbmod

But I need a $entdbmod() which will check if any occurrence of a entity is modified.
Okay, I can code a loop over all occurrence and whith the first $occdbmod() I leave the loop with true.
But i'm worried that it might take a while. :-)
Any other ideas?
Ingo


$entdbmod()



------------------------------
Ingo Stiller
Aareon Deutschland GmbH
------------------------------

Hi,

Other idea : use xmlsave/mod or componentToStruct/mod .

If the buffer/struct is empty , the entity is not modified.



------------------------------
Hortion Gilles
Dedalus Healthcare France
Artigues Pres Bordeaux FR
------------------------------

Hi,

Other idea : use xmlsave/mod or componentToStruct/mod .

If the buffer/struct is empty , the entity is not modified.



------------------------------
Hortion Gilles
Dedalus Healthcare France
Artigues Pres Bordeaux FR
------------------------------

Hi Hortion
ThanX for the hint
So I wrote this "simple" function to simulated $entdbmod()
It should be quick and do not flood the main memory with XML data (which unfortunately can happen)
And the componentToStruct statement is also not perfect
It returns all modified but not only DB-modified occurrences. 

Ingo

;
;SOF_ENTDBMOD(<instance>,<entity>,<para>)
;
;  checks if any of the occurrences of the entity has a DBMOD flag set
;
; Instance: not yet implemented
; Entity  : the considered entity
; para    ; for furher things
  returns boolean
  params
    string v_INST   :IN ; n/a
    string v_ENT_ID :IN
    string v_PARA   :INOUT
  endparams
  variables
    numeric v_COUNT
    boolean v_DB_MOD
    numeric v_STATUS
  endvariables
  IF(v_ENT_ID=="") v_ENT_ID = $entname
  v_COUNT = LLF_COUNT(v_ENT_ID)
  IF($status<0) RETURN("")
  IF(v_COUNT<50) ; less then 50 occurences, do it by a simple loop
    v_DB_MOD = LLF_LOOP(v_ENT_ID)
    IF($status<0) RETURN("")
  ELSE ; more then 49, convert the entity into a XML (but this could be a big struct?)
    v_DB_MOD = LLF_STRUCT(v_ENT_ID)
    IF($status<0) RETURN("")
  ENDIF
  IF(1) putmess "%%v_ENT_ID%%%  Count = %%v_COUNT%%%, DB_MOD = %%v_DB_MOD%%%"
  $status = 0 
  RETURN(v_DB_MOD)
END ;SOF_ENTDBMOD


ENTRY LLF_COUNT ; Count the occurrrences of an entity
  returns numeric
  params
    string v_ENT_ID:IN
  endparams
  variables
    numeric v_COUNT
    string  v_ENT_ID2
    numeric v_CUROCC2
  endvariables
  v_COUNT = $curhits(v_ENT_ID)
  IF(v_COUNT>0)
    $status = 0
    RETURN(v_COUNT)
  ENDIF
  v_ENT_ID2 = $entname()
  v_CUROCC2 = $curocc(v_ENT_ID2)

  setocc v_ENT_ID ,0
  lookup v_ENT_ID
  v_COUNT = $status

  setocc v_ENT_ID2,v_CUROCC2

  IF(v_COUNT<0)
    $status = v_COUNT
    RETURN("")
  ENDIF
  $status = 0
  RETURN(v_COUNT)
END ; LLF_COUNT


ENTRY LLF_LOOP
  returns boolean
  variables
    numeric v_CUROCC
    boolean v_DB_MOD
  endvariables
  reset $procerror
  v_CUROCC = $curocc(v_ENT_ID)
  IF($procerror<0)
    $status = $procerror
    RETURN("")
  ENDIF
  v_DB_MOD = 0
  FORENTITY v_ENT_ID
    IF($occdbmod(v_ENT_ID))
      v_DB_MOD = 1
      GOTO TAG_ENDE
    ENDIF
  ENDFOR
 TAG_ENDE:
  setocc v_ENT_ID,v_CUROCC
  $status = 0
  RETURN(v_DB_MOD)
END ; LLF_LOOP


ENTRY LLF_STRUCT
  returns boolean 
  params
    string v_ENT_ID:IN
  endparams
  variables
    struct  v_STRUCT
    numeric v_COUNT
  endvariables
  ; converts all ouccurences with $occmod or $occdbmod ?
  componentToStruct/mod v_STRUCT,v_ENT_ID
  IF($status<0) RETURN("")
  v_COUNT = v_STRUCT->$memberCount
  $status= 0
  IF(v_COUNT<=0)
    RETURN(0)
  ELSE
    RETURN(1)
  ENDIF
END ; LLF_STRUCT



------------------------------
Ingo Stiller
Aareon Deutschland GmbH
------------------------------

Hi,

Other idea : use xmlsave/mod or componentToStruct/mod .

If the buffer/struct is empty , the entity is not modified.



------------------------------
Hortion Gilles
Dedalus Healthcare France
Artigues Pres Bordeaux FR
------------------------------

some thoughts:-

1) Set a flag in the lmo, if a database field has changed using $fielddbvalue

2) set a flag in value changed, or leave field, or startmod of every field

3) you could code a flag in the write trigger.... the write trigger only fires for occurances that have been modified for writing... 



------------------------------
Osman Shariff
------------------------------