B4J Question Slow process of recording records

Discussion in 'B4J Questions' started by NinJavier, Feb 23, 2015.

  1. NinJavier

    NinJavier Member Licensed User

    Hi all. 144 records get a text file and insert into a table from a sqlite database. This process takes 14 seconds. Is there any way to speed up the process?
    The code is as follows:

    Dim m AsMap
    Dim Jsu AsStringUtils
    Dim Table, ListOfMaps AsList
    Log("Cargamos tabla " & DateTime.time(DateTime.Now))
    'cargamos el contenido del fichero texto en una lista
    Table = Jsu.LoadCSV("C:\General", "Ventas.txt", ";")

    Log("Iniciamos grabacion registros " & DateTime.time(DateTime.Now))

    For x = 0To Table.Size -1
    Dim cells() AsString
    cells = Table.get(x)


    m.Put("Serie", cells(0))
    m.Put("IdVenta", cells(1))
    m.Put("Estado", cells(2))
    m.Put("IdAlmacen", cells(3))
    m.Put("IdEmpleado", cells(4))
    m.Put("FormaDePago", cells(10))
    m.Put("Fecha", cells(11))
    m.Put("Hora", cells(12))
    m.Put("ID", cells(14))
    m.Put("Formato", cells(15))
    m.Put("Descripcion", "")
    m.Put("Cantidad", cells(16))
    m.Put("PrecioNUnidad", cells(17))
    m.Put("PrecioUnidad", cells(18))
    m.Put("Descuento", cells(19))
    m.Put("IdCliente", cells(20))
    'añado el mapa de campos a la lista
    DBUtils.InsertMaps(Main.SQL1, "Ventas", ListOfMaps)
    Log("Fin grabacion registros " & DateTime.time(DateTime.Now))

  2. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.

    Your code is wrong. You need to add all the maps to the list and then call InsertMaps once.
    NinJavier likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice