#include <dbinfo.ch>
REQUEST DBFCDX
#ifdef __XHARBOUR__
#xtranslate hb_threadStart( <x,...> ) => StartThread( <x> )
#xtranslate hb_threadJoin( <x,...> ) => JoinThread( <x> )
#endif
#define DBNAME "test"
#define NADD 1000
#define NTHREAD 10
proc Add100()
local i
RddSetDefault( "DBFCDX" )
SET DBFLOCKSCHEME TO DB_DBFLOCK_CLIP
? "use"
USE DBNAME SHARED
? "begin"
for i:=1 to NADD
dbAppend()
FIELD->RAND = hb_Random(100)
FIELD->TESTO = hb_randStr(10)
next
? "end"
return
proc main()
local i, oldR, threads
FERASE( DBNAME+".dbf" )
FERASE( DBNAME+".cdx" )
RddSetDefault( "DBFCDX" )
dbCreate( DBNAME, { { "ITEM", "N+", 10, 2 },{ "RAND", "N", 10, 2 },{ "TESTO", "C", 10, 0 } })
USE DBNAME SHARED
? "database done"
INDEX ON FIELD->RAND TAG "ITEST"
DBGOTOP()
? "INDEX done"
threads := {}
for i:=1 to NTHREAD
aadd(threads, hb_threadStart( @Add100() ))
next
for i:=1 to len(threads)
hb_threadJoin( threads[i] )
next
? "filled done"
OrdSetFocus( "ITEST" )
DBGOTOP()
oldR := FIELD->RAND
i := 0
dbSkip()
do while .not. eof()
if FIEL->RAND < oldR
i++
endif
oldR := FIELD->RAND
dbSkip()
enddo
? "There are " + str(i) + "error/s"
RETURN
Welcome Antonino,
Hi Antonino,
We want move to a SQL server scheme from DBF because:* There is always this problem of indices,I will try these setting hoping it will be fixed.
* Being a multi-user environment looks logic using a server-client database instead of all users use same files, crossing fingers that it works, and it don't because the indices become broken.
that index problem is very personal at you ! -- right done, none never problems !!, no 'finger crossing' needed.
Conclusion: something somewhere is wrong in your source/ environment.
I may suppose the SQLRDD formerly just hide a problem, as e.g. with different locking schemes for client side, or something else ...
For "server" Harbour would offer HbNetIO, and there is also external LetoDB.
But surely, both are DBF based. They communicate over TCP sockets, no remote desktop needed, just 'internet' connection.
BTW, i won't miss the DBF logic to lock a record, which SQL (without chin-ups) doesn't know -- then additional work around is needed.
( i never tried SQLRDD from xHarbour, i believe it does so .. )
As yourself said, then you have to rework the whole application.
There are some different approaches ready in Harbour, but AFIK not exactly as SQLRDD does.
And real SQL "rowset" versus DBF "record" are quite different strategies of database working.
Hi,
To my mind you can have two solutions.
1. If you want to move the sql way, you can use MySql+OTC Mediator+Harbour, advantage is very little change in code. More details available at www.otc.pl. (100 user license is free for MySql from OTC).
2. Use NETIO, examples and demos available in contrib\hbnetio folder. More reference available at https://hmgthinking.wordpress.com/ see post of 28/07/2015.
Having said that, I have never experienced any index corruption in DBF environment in both MultiUser and SingleUser versions of various softwares. I would suggest rechecking the code.
Warm regards,
Jayadev
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Since Clipper days, I never use COMMIT, only SKIP 0 after REPLACE.