Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Network and PACK problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm working on a network program with Clipper 5.3
I have this:
If upper(chr(cc)) = 'S'
R_lock() && Locks the record (Function)
Delete
Use pw_log exclusive && Log-on database
Pack
Use pw_log shared
* Index on pass to \farma\data\log1
* Index on user to \farma\data\log2
Endif
After this the Index is lost and I have to Index (*) again.
What do I wrong?
Thanks for an answer.
perloc@virconn.com
 
Whe you open the file exclusive, you must also open the indexes before you pack.


Use pw_log exclusive && Log-on database
set index to \farma\data\log1, \farma\data\log2
Pack

Use pw_log shared
set index to \farma\data\log1, \farma\data\log2



This way, once the file has been packed, the indexes will be rebuild.

Hope this helps.
 
I open my databases with my own function called
WIDEOOPEN()

3 Parameters contained within WIDEOPEN() are:-
- database name (in quotes)
- alias name (in quotes)
- Exclusive (T/F where T=exclusive and F=shared)

I also try to open files in SHARED mode as much as possible
because we never kow who might want to what, when...
This means that I use the EXCLUSIVE option for the minimum
time necessary to complete an EXCLUSIVE task and then
close the file as soon as possible thereafter...
(reopening the same file in SHARED mde if necessary)

example:-
IF .NOT. WIDEOPEN('sales', '', .F.)
* already EXCLUSIVE network access by another user
RETURN .F.
ENDIF
SET INDEX TO sales1,sales2,...etc

* then I do my maintenance...

* Updating record is done in a controlled way
DO WHILE .T.
IF REC_LOCK() && copyright (c) grumpfish
DELETE
DBCOMMIT()
UNLOCK
EXIT
ELSE
* make decisions if the record is locked
* but usually I just cycle around until it's free
ENDIF
ENDDO

Finally, if a pack is required I reopen the database
as soon as I can in EXCLUSIVE mode...

DO WHILE .T.
IF WIDEOPEN('sales', '', .T.)
EXIT
ENDIF
* already network access by another user - keep trying
ENDDO
SET INDEX TO sales1,sales2,...etc
PACK
USE

Then if I had to continue with the database I would open
it again, but this time in SHARED mode again...
IF .NOT. WIDEOPEN('sales', '', .F.)
* already EXCLUSIVE network access by another user
* make a decision to keep trying or not
ENDIF
SET INDEX TO sales1,sales2,...etc

Hope this helps,

Want a copy of WIDEOPEN() ? Free to good home.
Jim





 
Hola perlo:

PACK EN RED ES MORTAL!
PACK, IN THE NET NOOOOOOOOOOOOOO!

LEE EL SIGUIENTE DIAGRAMA:

Abri el archivo en modo compartido
OPEN A 'DBF' FILE IN SHARED MODE
abrí el o los índices para esta 'DBF'
OPEN A INDEX OR MORE

'Borrando el registro
'Deleting a record
busca el registro a borrar
SEEK THE RECORD TO DELETE
bloquea el registro con R_Lock() o tu propia función
LOCK THE RECORD WHIT R_LOCK(),OR YOUR FUNCTION
vacia el registro, campo por campo
BLANK IT, NOT DELETED()
FIELD BY FIELD
hace un COMMIT para vaciar el Buffer
COMMIT, FLUSH BUFFER
desbloquea el registro
UNLOCK
LISTO!
HECHO!

FIJATE QUE LA 'DBF' YA ESTA ABIERTA Y EL/LOS INDICES TAMBIEN

Para reusar este registro
'Reuse this record.
Busca un registro en blanco
SEEK A BLANK RECORD
Es final de archivo?
IF EOF()
SI, YES
lAppp := .T. // NOTE
ELSE
NO, NOT
POINT THIS RECORD
lApp := .F.
ENDIF

YOUR GET'S

IF lApp == .T.
APPEND BLANK
ELSE
LOCK A RECORD
ENDIF

SAVE A DATA
COMMIT
UNLOCK
HECHO!
OK.!

Esta técnica es muy buena sobre todo si tenes Archivos muy grandes y con varios indices abiertos al mismo tiempo, los operadores del Programa no deben esperar
que clipper termine el PACK, de esta manera no debes preocuparte por abrir 'DBF' en modo exclusivo, ya que
casi nunca lo necesitaras salvo para ti mismo y para
hacerle un mantenimiento, o un service.!

Si no te quedo claro, pone una nota en este foro y trataré de dejar un ejemplo real.

Sorry, my english is bad.

wht.






 
Lo que tienes que haces es iniciar tu aplicacion con:

Set Delete On
///esto hara que los registros borrados no te aparezcan
///aplicacion

Para usar el pack en red, todos los demas usuarios deben estar fuera de linea, o sin utilizar dicho archivo que quieres compactar.

Usa las funciones del CA-Tools en el archivo Network.prg

Net archivo Index Indice1, indice2, indiceN Shared

///busca lo que quieres borrar
RLock()
Delete
Unlock()

Close Data

Los registros marcados ya no apareceran en tus aplicacion o al mostrar datos, ni en los indices ya que tienes activado el modo que te puse al inicio.

ahora para empaquetar solo una persona debe tomar la decision, ya sea al final de las operaciones de la red, o en algun momento en el que todos los usuarios deben dejar de usar los archivos de datos.

usa lo siguiente:
Net archivo Index indice1, indice2, indiceN Exclusive
Pack
Close Data

Esto es efectivo, yo lo llevo usando asi desde hace mas de 3 años y no falla.

L.I.A. Ramon Zea
ramonzea@hotmail.com
ramonzea@yahoo.com
 
PACK YOUR DATABASE AFTER USER DELETE A RECORD IS A BAD METHOD.(REQUIRE CLOSE AND REOPEN THE DATABASE)

PLAN TO USE REUSAGE OF DELETED RECORDS IS THE BEST METHOD
AND NOT NEED PACK YOUR DATABASE.

REMEMBER AFTER DELETE A RECORD THE DATABASE IS IN INCONSISTENT STATE IF YOU USE SET DELETED ON AN NEED A RECORD REPLACEMENT EX: DBSKIP() DBSKIP(-1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top