PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → SQL to HFSQL
SQL to HFSQL
Iniciado por HECTOR, 29,jul. 2016 18:55 - 2 respuestas
Miembro registrado
26 mensajes
Publicado el 29,julio 2016 - 18:55
Hi everyone. I want to create a program that can connect to a SQLServer database, access a table and create a local copy on HFSQL.

I have already written a code that works but its performance is very low, any suggestions?

My actual code:


Procedure SQLtoHFSQL(cServer, cUser, cPass, cBase, cTableName)


ConnectionNum is int
ConnectionNum = SQLConnect(cServer, cUser, cPass, cBase,"OLEDB",hOledbSQLServer)

IF ConnectionNum <> 0 THEN

cQuery is string = "select * from " + cTableName


IF SQLExec(cQuery, "oQry") THEN


aColumnas is array of strings
aCol is array of strings
nCol is int = 1



// Creamos la descripcion del .Fic
oFile is File Description

oFile..Name = "oData"
oFile..Type = hFileNormal


// Describimos todos los items que contendrá el .Fic
oItem is Item Description
nTipo is int

StringToArray(SQLColumn("oQry", True),aColumnas,CR)

nColumnas is int = SQL.NbCol

WHILE nCol <= nColumnas

StringToArray(aColumnas[nCol],aCol,TAB)


IF aCol[2] = "T" THEN
nTipo = hItemText
ELSE
IF aCol[3] = "1" THEN
nTipo = hItemBoolean
ELSE
nTipo = hItemNumeric
END
END

oItem..Name = aCol[1]
oItem..Type = nTipo
oItem..Size = aCol[4]
HDescribeItem(oFile,oItem)

nCol++
END

HDescribeFile(oFile)


// Creamos el archivo fisico que contendrá los datos
oData is Data Source
HChangeName(oData,Replace(cTableName,".","_"))
HCreation(oData)

StringToArray(SQLColumn("oQry"),aColumnas,CR)

WHILE SQLFetch("oQry") = 0

nCol = 1

WHILE nCol <= nColumnas

HToItem(oData, nCol, SQLGetCol("oQry", nCol))

nCol++
END

HAdd(oData)
END

ELSE
SQLInfo("oQry")
Info("SQL error: " + SQL.MesError)
END

SQLDisconnect()
END
Publicado el 01,agosto 2016 - 13:50
Hi

What is "very low" ?

1. YOu can create the file description in the analysis, just by
conecting to your existing SQL DB

2. You can inactivate the indexes on the HF file, and reactivate them
AFTER the loop, it's much faster

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

More information on http://www.fabriceharari.com
Miembro registrado
26 mensajes
Publicado el 01,agosto 2016 - 16:19
Hi Fabrice.

1. I don't want to describe any file in the analysis, I want to dynamically build this files and fill them with the data from the server

2. I don't know how to do this