Lazarus

Programming => Packages and Libraries => LazReport => Topic started by: andersonscinfo on April 10, 2019, 02:58:30 pm

Title: Script with while, advancing in query / dataset.
Post by: andersonscinfo on April 10, 2019, 02:58:30 pm
Hi, I'm trying to make a script where I need to forward a query / dataset type like this:
Code: Pascal  [Select][+][-]
  1. begin
  2.   vreal:=0.00;
  3.   [Data.SQL3.FIRST];
  4.   while [Data.SQL3.EOF] do
  5.   begin
  6.     if ([Data.SQL3."VALOR"] > 0) then
  7.       vreal:=vreal+[Data.SQL3."VALOR"];
  8.     [Data.SQL3.NEXT];
  9.   end;
  10.   Text:= FORMATFLOAT(['#,##0.00'], vreal)]);
  11. end;        
  12.  

https://i.imgur.com/ABLNuj4.png (https://i.imgur.com/ABLNuj4.png)

but I do not know how to access the methods, first, next, and eof, does anyone have any suggestions?

I'm using google translator.

#Portugues/Brazil

Script com while, avançando na query/dataset.

Ola, eu estou tentando fazer um script onde preciso avançar uma query/dataset tipo assim:

mas não sei como acessar os métodos, first, next, e eof, alguem tem alguma sugestão?

estou usando google translator.
Title: Re: Script with while, advancing in query / dataset.
Post by: valdir.marcos on April 10, 2019, 03:05:46 pm
Hi, I'm trying to make a script where I need to forward a query / dataset type like this:
Code: Pascal  [Select][+][-]
  1. begin
  2.   vreal:=0.00;
  3.   [Data.SQL3.FIRST];
  4.   while [Data.SQL3.EOF] do
  5.   begin
  6.     if ([Data.SQL3."VALOR"] > 0) then
  7.       vreal:=vreal+[Data.SQL3."VALOR"];
  8.     [Data.SQL3.NEXT];
  9.   end;
  10.   Text:= FORMATFLOAT(['#,##0.00'], vreal)]);
  11. end;        
  12.  

https://i.imgur.com/ABLNuj4.png (https://i.imgur.com/ABLNuj4.png)

but I do not know how to access the methods, first, next, and eof, does anyone have any suggestions?

I'm using google translator.

#Portugues/Brazil

Script com while, avançando na query/dataset.

Ola, eu estou tentando fazer um script onde preciso avançar uma query/dataset tipo assim:

mas não sei como acessar os métodos, first, next, e eof, alguem tem alguma sugestão?

estou usando google translator.
Não entendi porque você está usando a palavra "script"...
De qualquer maneira, não seria mais simples vocês fazer um "Select Sum(Valor) From Tabela Where Codigo = :Codigo;"?

I can't guess what you mean with "script" word in this case...
Anyway, would it be simpler if you just used a "Select Sum(Valor) From Tabela Where Codigo = :Codigo;"?
Title: Re: Script with while, advancing in query / dataset.
Post by: andersonscinfo on April 10, 2019, 03:12:39 pm
ola @valdir.marcos obrigado por responder...

estou usando a palavra script porque é um script de um memo do lazreport, quero efetuar o calculo no script do memo, não posso usar o select como sugeriu, é um código automatizado, onde não posso adicionar outros sql's alem dos quem ja vem na construção da aplicação, preciso calcular com base nos dados que tenho ja carregados, abre a imagem em anexo ao tópico para ver porque usei a palavra script, eu não sei se não seria apropriado usar a palavra.

hello @ valdir.marcos thanks for responding ...

I am using the word script because it is a script from a lazreport memo, I want to perform the calculation in the memo script, I can not use the select as it was suggested, it is an automated code, where I can not add other sql's besides those already in the construction of the application, I need to calculate based on the data I have already loaded, open the image attached to the topic to see why I used the word script, I do not know if it would be appropriate to use the word.
Title: Re: Script with while, advancing in query / dataset.
Post by: jesusr on May 12, 2019, 08:46:18 am
https://i.imgur.com/ABLNuj4.png (https://i.imgur.com/ABLNuj4.png)

It looks like you want to sum some field, if SQL3 is your dataset, and VALOR your field, use an expression like [SUM([SQL3."VALOR"], YourBandName)]
TinyPortal © 2005-2018