PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Translates records from a local HFSQL table to a remote one.
Translates records from a local HFSQL table to a remote one.
Débuté par Enrique A., 02 sep. 2014 22:02 - 2 réponses
Posté le 02 septembre 2014 - 22:02
Hi people. I would like to optimize a process (WX19) which translates records from a local HFSQL table to a remote one, both identical in structure. Data can be as large as 500,000 records.
The connection between both tables is stablished using the internet.
The local table has an active filter (Control=0) in order to have the records that need to be exported or migrated to the remote table
Once each local record is migrated to the remote table the local table is marked as exported setting the field Control=1

Thanks in advance.

Sample code to optimize:

HDeactivateFilter(Facturas_Totales)
HFilter(Facturas_Totales,Control,0)
HReadFirst(Facturas_Totales)

WHILE NOT HOut(Facturas_Totales)

HCopyRecord(Facturas_Totales_R,Facturas_Totales)

HAdd(Facturas_Totales_R)

Facturas_Totales.Control=1
HModify(Facturas_Totales)

HReadNext(Facturas_Totales)
END
HDeactivateFilter(Facturas_Totales)?
Posté le 03 septembre 2014 - 01:15
Here is the way i duplicate the database or load the database from hf to sqlite and copy
it to smartphone. You could also copy one database hf to another hf or mysql just
change the provider.
suppose you have allready defined connection and opened it.

sFiles is string = "list of filenames extracted from analyse or harcoded delimited by " + TAB + "tabs"
ctnewdb is Connection
ctnewdb..Provider =hNativeAccessSQLite
ctnewdb..Access =hOReadWrite
ctnewdb..Server = "newdatabasename.db" // new database hf sql or whatever
ctnewdb..User = ""
ctnewdb..Password = ""
ctnewdb..Database = ""
HSetTrigger(False)

IF HOpenConnection(ctnewdb) THEN
ELSE
RETURN
END
dsFajl is Data Source
FOR EACH STRING sName OF sFiles SEPARATED BY TAB
SQLTransaction(sqlStart,ctnewdb)

IF HExecuteSQLQuery(dsFajl, hQueryDefault, "SELECT * FROM " + sName) THEN
ELSE
Info(HErrorInfo(hErrFullDetails))
END

IF HChangeConnection(sName,ctnewdb) THEN
IF HCreationIfNotFound(sName) THEN
ELSE
Info(HErrorInfo(hErrFullDetails))
END
END
FOR EACH dsFajl
HReset(sName)
HCopyRecord(sName,dsFajl,hCopyAutoId+hDefaultVal)
IF HAdd(sName) THEN
ELSE
IF HErrorDuplicates() THEN
Info(HErrorInfo(hErrFullDetails))
ELSE

END

END
END
SQLTransaction(sqlCommit,ctnewdb)
HCancelDeclaration(dsFajl)
END
HConnectionClose(ctnewdb)
HSetTrigger(True)
Posté le 03 septembre 2014 - 18:29
Hi Novica

Thank you for your help.

I will analize the code.

Regards,

Enrique