Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
3
Erster Beitrag:
vor 3 Jahren, 11 Monaten
Letzter Beitrag:
vor 3 Jahren, 11 Monaten
Beteiligte Autoren:
Enrique A., Novica Njagojevic

Translates records from a local HFSQL table to a remote one.

Startbeitrag von Enrique A. am 02.09.2014 20: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)

Antworten:

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)

von Novica Njagojevic - am 02.09.2014 23:15
Hi Novica

Thank you for your help.

I will analize the code.

Regards,

Enrique

von Enrique A. - am 03.09.2014 16:29
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.