FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour simulate dbzap
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
simulate dbzap
Posted: Wed Jan 02, 2019 05: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 (fw): Select all Collapse
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 (fw): Select all Collapse
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 March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: simulate dbzap
Posted: Thu Jan 03, 2019 01: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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: simulate dbzap
Posted: Thu Jan 03, 2019 06: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 March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: simulate dbzap
Posted: Thu Jan 03, 2019 06: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: simulate dbzap
Posted: 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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: simulate dbzap
Posted: Fri Jan 04, 2019 01: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 March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: simulate dbzap
Posted: Fri Jan 04, 2019 01: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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: simulate dbzap
Posted: Fri Jan 04, 2019 01: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 March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: simulate dbzap
Posted: 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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: simulate dbzap
Posted: Sat Jan 05, 2019 06:30 PM

I resolved without dbzap

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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

Continue the discussion