simulate dbzap

simulate dbzap

Postby Silvio.Falconi » Wed Jan 02, 2019 5:58 pm

I need to erase all record from a database open with share mode and replace all record from an array with FW_ArrayToDBF function

I cannot use dbzap because it want exclusive mode

is there another solution ?

I'm thinking to use this function but it not run and crash the procedure

Code: Select all  Expand view  RUN
Function allRecordErase(cAlias)
  local nRecord := (cAlias)->(Recno())
      local nNext

   Do While .not. (cAlias)->(eof())
         (cAlias)->(DbSkip())
                 nNext := (cAlias)->(Recno())
                      (cAlias)->(DbGoto(nRecord))
                          IF!Occupato((cAlias))
                              (cAlias)->(DbDelete())
                              (cAlias)->(DbCommit())
                              (cAlias)->(DbUnlock())
                           ENDIF

                  (cAlias)->(DbGoto(nNext))

                   if (cAlias)->(EOF()) .or. nNext == nRecord
                      (cAlias)->(DbGoBottom())
                   endif
       (cAlias)->(dbSkip())
    Enddo

return nil


Occupato function
Code: Select all  Expand view  RUN
FUNCTION Occupato(cAlias)
   LOCAL lRet:=.F., nTimes:=5
   DEFAULT cAlias:=Alias()
   DO WHILE nTimes>0
      IF (cAlias)->(RLock())
         nTimes:=0
      ELSE
         INKEY(0.5)
         nTimes:=nTimes-0.5
         IF nTimes<=0 .AND.;
            MsgYesNo("!Record  occupato da un altro utente!, ¿Continuare?","Conferma...")
            nTimes:=3
         ELSE
            lRet:=.T.
         ENDIF
      ENDIF
   ENDDO
   RETURN (lRet)
 


any solution please ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: simulate dbzap

Postby James Bott » Thu Jan 03, 2019 1:35 am

You must open the file in exclusive use mode. Even in a multi-user app.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: simulate dbzap

Postby Silvio.Falconi » Thu Jan 03, 2019 6:06 pm

there is a method

Local nRecords:= (cAlias)->(reccount())

For n= 1 to nRecords
(cAlias)->(DbGoto(n))
IF!Occupato((cAlias))
(cAlias)->(DbDelete())
(cAlias)->(DbCommit())
(cAlias)->(DbUnlock())
ENDIF
next


the problem is then how recreate the index file cdx or refresh it
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: simulate dbzap

Postby James Bott » Thu Jan 03, 2019 6:26 pm

The deleted records are still there. You will still have to zap the file to remove them.

Or, you could just over-write all the existing records with data from the array. No deleting or zapping required.

But if this procedure is only done by an Admin, then you just have to make sure no other users are in the app, then use your original routine one the file opened in exclusive use.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: simulate dbzap

Postby James Bott » Fri Jan 04, 2019 12:04 am

>I need to erase all record from a database open with share mode and replace all record from an array with FW_ArrayToDBF function

1) What is in this database?

2) Why does it need to be in shared use? Is it because more than one person needs to access it at the same time, or is it because you think that ALL databases in a multi-user app must be opened in shared mode?
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: simulate dbzap

Postby Silvio.Falconi » Fri Jan 04, 2019 1:14 am

I explained it to you in private

have you sold an application that has an archive of items to make an invoice to a person ok?

does this person like when he makes the bill to select items from a list ok?

but does this person like to display some articles before instead of others ok?

so in order to display the personalized list of these articles you have to make sure to index them in a certain way

add a numeric field to the database "display" 1 N

and that person enters a number corresponding to the display number

after you index for that field and you will have the custom list

did you understand up to this point?

instead of inserting a number in the numeric field, I made a dialog where your person (to whom you sell the program) could move the elements of this list with the mouse, ie move them to position

to do this I create a temporary array from the archive and show this array into a xbrowse ok ?

then with two buttons I give the end user the ability to move the elements in the array


at the end the user must save the positions

to save the positions I have to reinsert the array in the archive

because I have the same records of archive but with the value changed in that numeric field "Display"

so I have to delete the database records and insert the records from the array

dbzap
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: simulate dbzap

Postby James Bott » Fri Jan 04, 2019 1:18 am

Silvio,

Did you get the private email I sent explaining how to do this and why?
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: simulate dbzap

Postby Silvio.Falconi » Fri Jan 04, 2019 1:25 am

forget it I understood that I have to give up too hard for you to understand, yet it is so simple and crystalline

I am the owner of the plant and I have a computer open on the planning of the beach

my lifeguard who works at the beach opens the program (lan) and inserts a new multiple service for example boat trip with a view to the sharks and fishing

my lifeguard orders the display of services

but he can not do it because my friend James did not understand what I have to do for the archives if they are open in share mode then you can not use dbzap and insert a database array with the function fw_arraytodb

It's unbelievable .... I'm just wasting time
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: simulate dbzap

Postby James Bott » Fri Jan 04, 2019 10:02 pm

Or, you could do, as I said at the start of this message thread:

Or, you could just over-write all the existing records with data from the array. No deleting or zapping required.


http://forums.fivetechsupport.com/viewtopic.php?f=3&t=36558&p=218106#p218100
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: simulate dbzap

Postby Silvio.Falconi » Sat Jan 05, 2019 6:30 pm

I resolved without dbzap
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: SantaCroya and 54 guests