Primeiro, troque esta macro por um code block:
Código: Selecionar todos
LOCAL bWhile := { || ! EOF() }
While Eval( bWhile )
...
EndCódigo: Selecionar todos
03 @ 06,16 say str(WQTD)
04 @ 07,19 say CARROMonte blocos, por exemplo de 200 registros e insira de uma vez...
Código: Selecionar todos
#include "ado.ch"
PROCEDURE DbfImport()
LOCAL bWhile, nCount, cString, cSQL, nQtd, nTotal
bWhile := { || <condição while> }
cString := "INSERT INTO QTRACS (CARRO, MCT, LATITUDE, LONGITUDE, DATA, HORA, VELOC, LOCAL) VALUES "
nCount := 0
nQtd := 200
While Eval( bWhile )
If nCount == 0
cSql := cString
Endif
cSql += "( '" + alltrim(CARRO) + "', "
cSql += "'" + alltrim(MCT) + "', "
cSql += "'" + alltrim(LATITUDE) + "', "
cSql += "'" + alltrim(LONGITUDE) + "', "
cSql += "'" + Transform( ( dtos( DATA ), "@R 9999-99-99" ) + "', "
cSql += "'" + alltrim(HORA) + "', "
cSql += "'" + alltrim(alltrim(str(VELOC))) + "', "
cSql += "'" + alltrim(LOCAL) + "' ) "
nCount += 1
If nCount == nQtd
cSql += ";"
oConexao:Execute( cSql )
nTotal += nCount
nCount := 0
cSql := ""
DispOutAt( 06, 16, Str( nTotal ) ) // Evita carregar o Get System (@... SAY)
DispOutAt( 07, 19, CARRO )
Else
cSql += ", "
Endif
DbSkip()
End
If ! Empty( cSql )
oConexao:Execute( cSql )
Endif
DispOutAt( 06, 16, Str( nTotal ) + " Registros incluidos" )
DbCloseAll()
If oConexao:state == adStateOpen
oConexao:close()
Endif
oConexao := NIL
RETURN


