how to find out if a Record was updated ?

how to find out if a Record was updated ?

Postby Jimmy » Wed Jun 05, 2024 3:18 pm

hi,

i think LUpdate() does not work any more, so how can i find out if Data was updated ?
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to find out if a Record was updated ?

Postby karinha » Wed Jun 05, 2024 4:54 pm

Code: Select all  Expand view

// C:\FWH\SAMPLES\JIMMYUPD.PRG

#include "FiveWin.ch"

FUNCTION Main()

   SET CENTURY ON
   SET DATE BRITISH
   SET EPOCH TO YEAR( DATE() ) - 30

   USE CUSTOMER NEW

   ? LUpdate()

   CLOSE DATABASES
 
   ? Date()

   USE Sales NEW

   ? LUpdate()

   APPEND BLANK

   ? LUpdate()

   CLOSE DATABASES

   USE Sales NEW

   ? LUpdate()

   /* This example uses an aliased expression TO access LUpdate()
      FOR a DATABASE FILE opened in an unselected work area: */


   USE Sales NEW
   USE Customer NEW

   ? LUpdate(), Sales->( LUpdate() )

RETURN NIL

// Library is rdd

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: how to find out if a Record was updated ?

Postby Jimmy » Thu Jun 06, 2024 10:04 am

hi,

thx for working Sample
i have forgot that i need to CLOSE DBF and reOPEN it to get it work

but Lupdate() just return a Date, but no Time so it work just once a Day to inform that DBF have changed.

so my Question was wrong : how to find out if a Record was now (!) updated ?
i want to inform other User, if they use same DBF, that e.g. a Browse Display refresh() is need
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to find out if a Record was updated ?

Postby MarcoBoschi » Thu Jun 06, 2024 11:38 am

Dear Jimmy,
You have to create two fields in every table by yourself.
Every dbf table I use in my program has two fields UTEMODI C3 and DATMODI C14
When I modify even one single fields in a record I also write user code and date time
For instance

REPLACE field->utemodi WITH "001" , ;
field->datmodi WITH DTOS(DATE())+STRTRAN(TIME(),":","")

Very very useful for many things I can do that I'm not here to write. You can imagine it.
I even create an index for this two fields 8)
Someone who read this my post would think is not useful but Jimmy believe me.
In many years this two simple fields permit to me to understand some strange problems in user report.

Have a nice day
Marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: how to find out if a Record was updated ?

Postby karinha » Thu Jun 06, 2024 12:28 pm

Jimmy, simples:

Code: Select all  Expand view

// C:\FWH\SAMPLES\JIMMYDTH.PRG

#include "FiveWin.ch"

FUNCTION JimmyDtH()

   LOCAL cFile, aDir, dDBF, dDBF2, dDBF3, dDBF4  // etc...

   SET CENTURY ON
   SET DATE BRITISH
   SET TIME FORMAT TO "HH:MM:SS"
   SET EPOCH TO YEAR( DATE() ) - 30

   IF FILE( "CUSTOMER.DBF" )

      cFILE := "CUSTOMER.DBF"

      aDIR  := Directory( cFILE )

      dDBF  := aDIR[ 1 ][ 3 ] // date

      dDBF2 := aDIR[ 1 ][ 4 ] // Hours

      ? "Date: ", dDBF, "Hours:", dDBF2

   ENDIF

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: how to find out if a Record was updated ?

Postby Rick Lipkin » Thu Jun 06, 2024 12:56 pm

Jimmy

All you need to do is add two fields to your database table

cUser := WNetGetUser() // FiveWin function
cUser := UPPER( cUser )


"LastUpdate" "D" 8 and "UpdatedBy" "C" 15

When you add or save a record just update the lastupdate field with Date() and UpdatedBy by the person logged into the computer with the above example using WNetGetUser()

You can even create a USer Table and assign user rights like User Admin Super Write ReadOnly
Lipkinrm Y Y N N

This is the way I use WNetGetUser() like Single Sign On ..

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: how to find out if a Record was updated ?

Postby Jimmy » Fri Jun 07, 2024 4:30 am

hi,
karinha wrote:Jimmy, simples:
// C:\FWH\SAMPLES\JIMMYDTH.PRG

i had same Idea, but it take some Time before i got Result.
DBF was not Update immediately when Data have changed, it take some Minutes before Directory show it ?

seems i have to include a Timestamp Field into every DBF which i want to check.
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to find out if a Record was updated ?

Postby MarcoBoschi » Fri Jun 07, 2024 7:01 am

Jimmy,
and what about to write in another dbf all these timestamp?
Have a nice day
Marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: how to find out if a Record was updated ?

Postby Otto » Fri Jun 07, 2024 7:25 am

Hello Jimmy,

Have you read this thread? I think this is the same topic as your problem.

Have a nice weekend,

Otto
https://forums.fivetechsupport.com/viewtopic.php?f=3&t=43815&p=264715&hilit=commit&sid=3186b6f54fda099a61d78ae8e9958702&sid=8728c4d990f9d85d3869ed22b7300231#p264715
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: how to find out if a Record was updated ?

Postby Jimmy » Fri Jun 07, 2024 10:39 am

hi Otto,

THX for the link, i will read it
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to find out if a Record was updated ?

Postby karinha » Fri Jun 07, 2024 12:05 pm

Jimmy,

Code: Select all  Expand view

   COMMIT
   UNLOCK
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 68 guests