Comparing fields

Yohn

Member
Hy
I have doing some buffer compare, and I need save result in list. My question is how can I write these changes in other table. For example if I have to change customer records, fields name and address, then I need to compare old record with new and write that new record in other table, but not like field_name, but like field_name:customer.
Thx.
 

newprog

New Member
You could put it in a write trigger for the table if you are able to do that?

Code:
TRIGGER PROCEDURE FOR WRITE OF address OLD BUFFER bAddress
.

You can then compare what you want and write to any table you want. Without more info on what you want specifically I can't really suggest anything else.
 

Yohn

Member
code sample:

IF STRING(tProdajnaMjesta.sifpm) <> STRING(prod-mjesto.sifpm) THEN
ASSIGN cPromjena = cPromjena + "sifpm:" + STRING(prod-mjesto.sifpm) + " ".

IF tProdajnaMjesta.naziv <> prod-mjesto.naziv THEN
ASSIGN cPromjena = cPromjena + "naziv:" + prod-mjesto.naziv + " ".

IF tProdajnaMjesta.adresa <> prod-mjesto.adresa THEN
ASSIGN cPromjena = cPromjena + "adresa:" + prod-mjesto.adresa + " ".

cImePrograma = "Unos/Izmjena PM".
CREATE eva.
ASSIGN
eva.datum = TODAY
eva.ime-korisnika = USERID("dictdb")
eva.ime-programa = cImePrograma
eva.pocetak = cPromjena.

I just want to write changed fields to eva, not all of them.
 

newprog

New Member
You don't have to write all of them. You can put your code sample into the trigger like below. I'm assuming tProdajnaMjesta is a buffer of prod-mjesto in this example.

Code:
TRIGGER PROCEDURE FOR WRITE OF prod-mjesto OLD BUFFER tProdajnaMjesta.
 
DEFINE VARIABLE cPromjena AS CHARACTER NO-UNDO.
 
IF STRING(tProdajnaMjesta.sifpm) <> STRING(prod-mjesto.sifpm) THEN 
ASSIGN cPromjena = cPromjena + "sifpm:" + STRING(prod-mjesto.sifpm) + " ".
 
IF tProdajnaMjesta.naziv <> prod-mjesto.naziv THEN
ASSIGN cPromjena = cPromjena + "naziv:" + prod-mjesto.naziv + " ".
 
IF tProdajnaMjesta.adresa <> prod-mjesto.adresa THEN
ASSIGN cPromjena = cPromjena + "adresa:" + prod-mjesto.adresa + " ".
 
cImePrograma = "Unos/Izmjena PM". 
 
IF cPromjena <> "" THEN
DO:
  CREATE eva.
  ASSIGN  
  eva.datum = TODAY
  eva.ime-korisnika = USERID("dictdb")
  eva.ime-programa = cImePrograma
  eva.pocetak = cPromjena.
END.

Hope this helps.
 

newprog

New Member
I'm still a bit confused over what you are trying to achieve but that's probably me. Completely misunderstood your problem first time round.

This code will give you the changed fields in a comma-separated list which you could then go through and write to your table. This would only give you the changed fields in the list.

Code:
def temp-table ttaddress like address.
def var cresult as char format "x(60)".
 
/* 
   changes to temp-table in here .
   more code (find address).
*/
 
buffer-compare ttaddress to address save result in cresult.
disp cresult.

HTH
 
Top