[Lazarus-es] leer todos los Record con SQLdb

Maxi maximiliano.duarte en gmail.com
Vie Nov 4 14:52:29 CET 2016


como es un motor y uno trae datos "por la red" para no generar un trafico
innecesario solo trae algunos registros. Al hacer last si o si debe
recorrer la seleccion para obtener todos los registros.
Me pasó en mySql


El 4 de noviembre de 2016, 8:37, Rafael Bidegain via Lazarus-es <
lazarus-es en lists.lazarus-ide.org> escribió:

> Hola Hector.
>
> No puedo hacer pruebas como para darte una respuesta mas precisa.
> busqué el documento al que haces referencia y encontré un texto pero
> entiendo que 'el truco' de llamar a .last es solo para poder utilizar la
> propiedad RecordCount.
>
> en el ejemplo que enviaste no veo que estés usando esa propiedad, ¿tenés
> dudas sobre el funcionamiento del select?
>
> Creo que si tenés necesidad de ejecutar el método last deberías hacerlo así
>  fdm.SQLQuery1.Last();
>
> si yo tuviese que la necesidad de saber la cantidad de registros de un
> query setearía la propiedad .PacketRecords' en -1 tal como se indica en
> el documento.
>
> Lamento disponer de un lazarus para hacer pruebas.
>
> saludos cordiales, es un gusto leerte otra vez.
>
> http://wiki.freepascal.org/SqlDBHowto
>
> Why does TSQLQuery.RecordCount always return 10?
>
> To count the records in a dataset, use '.RecordCount'. However, notice
> that '.RecordCount' shows the number of records that is already loaded from
> the server. For performance reasons, SqlDB does not read all records when
> opening TSQLQuery by default, only the first 10. Only when the eleventh
> record is accessed will the next set of 10 records be loaded, etc. Using
> '.Last', all records will be loaded.
>
> When you want to know the real number of records on the server you can
> first call '.Last' and then call '.RecordCount'.
>
> An alternative is available. The number of records returned by the server
> is set by the '.PacketRecords' property. The default value is 10; if you
> make it -1 then all records will be loaded at once.
>
> In current stable FPC, '.RecordCount' does not take filters into account,
> i.e. it shows the unfiltered total.
>
> If you need the exact number of records, it often is a better idea to
> directly query the number of records in a query using another SQL query,
> but you would have to do that in the same transaction, as other
> transactions may have changed the number of records in the meanwhile.
>
> El 4 de noviembre de 2016, 7:20, hfiandor via Lazarus-es <
> lazarus-es en lists.lazarus-ide.org> escribió:
>
>> Amigos listeros:
>>
>>
>>
>> En el documento SQLdb How to do se explica por qué solamente se leen los
>> primeros 10 registros al ejecutar una consulta y brinda una solución para
>> que lea todos los registros.
>>
>>
>>
>> Tengo una aplicación donde hago lo siguiente:
>>
>>   begin
>>
>>
>>
>>     fdm.SQLQuery1.Active := False;
>>
>>     fdm.dsSQLQuery1.DataSet:=fdm.tTemp2;
>>
>>     fdm.SQLite3Connection1.DatabaseName:=camino_BD + '\temp.db';
>>
>>     fdm.SQLQuery1.SQL.Text := 'SELECT * FROM Temp2 WHERE codNegSerAct =
>> :SelCodigoNegSerAct ORDER BY codNegSerAct';
>>
>>     fdm.SQLQuery1.Params.ParamByName('SelCodigoNegSerAct').AsString :=
>> SelNSA;
>>
>>     fdm.SQLQuery1.ExecSQL;
>>
>>     fdm.tTemp2.Last; //para que lea completo
>>
>>
>>
>>     if fdm.SQLQuery1.Active = False then fdm.SQLQuery1.Active := True
>>
>>     else begin end;
>>
>>     fEstadoCuenta_2.frDBDataSet2.DataSet := fdm.SQLQuery1;
>>
>>     fEstadoCuenta_2.frReport2.LoadFromFile(camino_actual+'\plant
>> illas\Extendida_2.lrf');
>>
>>     fEstadoCuenta_2.frReport2.ShowReport;
>>
>>
>>
>>     fdm.SQLQuery1.Close;
>>
>>     fdm.SQLTransaction1.Active := False;
>>
>>     fdm.SQLite3Connection1.Connected := False;
>>
>>
>>
>> No tengo la certeza de haber escrito la instrucción    fdm.tTemp2.Last;
>> //para que lea completo en el lugar correcto.
>>
>>
>>
>> Agradecería que alguien me comentara al respecto y cualquier otra
>> sugerencia que deseen.
>>
>>
>>
>> Saludos
>>
>> Ing. Héctor F. Fiandor Rosario
>>
>>
>>
>> _______________________________________________
>> Lazarus-es mailing list
>> Lazarus-es en lists.lazarus-ide.org
>> http://lists.lazarus-ide.org/listinfo/lazarus-es
>>
>>
>
>
> --
> Rafael Bidegain
>
> Ya que los cuerdos no hablan, hablará el loco.
> (The Fool, Padraic Pearse)
>
> # yo quiero educación libre. ¡YA!
>
>
> _______________________________________________
> Lazarus-es mailing list
> Lazarus-es en lists.lazarus-ide.org
> http://lists.lazarus-ide.org/listinfo/lazarus-es
>
>


-- 
El que pregunta aprende, y el que contesta aprende a responder.

No a la obsolecencia programada:
http://www.rtve.es/noticias/20110104/productos-consumo-duran-cada-vez-menos/392498.shtml

Linux User #495070
http://domonetic.com/blog
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus-es/attachments/20161104/b6716489/attachment-0001.html>


Más información sobre la lista de distribución Lazarus-es