Erro na consulta SQL no formato currency.
Bom dia pessoal,
Estou com dificuldade para consultar valores em uma tabela entre os valores calculados a partir de um valor inserido em um Edit, o resultado deve ser no formato Currency.
Segue exemplo do que eu estou precisando fazer mas desta forma o sistema me retorna o erro 'invalid use of Keyword. Token: ,00'
procedure T_pesquisa.BitBtn1Click(Sender: TObject);
var
valores, v_maior, vr_menor, percentual: Currency;
begin
valores := StrToFloat(valor.Text); // valor original
percentual := 10.0 / 100.0; // 10%
vr_maior := valores + (percentual * valores);
vr_menor := valores - (percentual * valores);
EditMaior.Text:= FormatCurr(',##0.00', v_maior);
EditMenor.Text:= FormatCurr(',##0.00',v_menor);
Qryqimo.close;
Qryqimo.sql.clear;
Qryqimo.SQL.Add('select * from imovel where imovel.valor between '+(Editmaior.Text)+' and '+(Editmenor.Text)+'');
Qryqimo.open;
end;
var
valores, v_maior, vr_menor, percentual: Currency;
begin
valores := StrToFloat(valor.Text); // valor original
percentual := 10.0 / 100.0; // 10%
vr_maior := valores + (percentual * valores);
vr_menor := valores - (percentual * valores);
EditMaior.Text:= FormatCurr(',##0.00', v_maior);
EditMenor.Text:= FormatCurr(',##0.00',v_menor);
Qryqimo.close;
Qryqimo.sql.clear;
Qryqimo.SQL.Add('select * from imovel where imovel.valor between '+(Editmaior.Text)+' and '+(Editmenor.Text)+'');
Qryqimo.open;
end;
Valdir Lima
Curtidas 0
Respostas
Wilton Júnior
27/05/2011
with Qryqimo do
begin
close;
sql.clear;
SQL.Add('select * from imovel where valor between '+(Editmaior.Text)+' and '+(Editmenor.Text));
open; end; Cara tenta fazer dessa forma mas eu acho que o problema esta na passagem de float para str.
SQL.Add('select * from imovel where valor between '+(Editmaior.Text)+' and '+(Editmenor.Text));
open; end; Cara tenta fazer dessa forma mas eu acho que o problema esta na passagem de float para str.
GOSTEI 0
Valdir Lima
27/05/2011
Olá Wilton,
Eu fiz as alterações mas continua dando o mesmo erro, o erro está na linha do Select, talvez como você disse, eteja na passagem de float para str ou coisa parecida pois o campo valor na tabela está no formato currency (R$ 23.000,00) e eu preciso que a minha consulta traga no meu DBGrid os valores entre o maior e o menor que a consulta encontrar.
procedure T_pesquisa.BitBtn1Click(Sender: TObject);
var
valores, valor_maior, valor_menor, percentual: Currency;
begin
valores := StrToFloat(valor.Text); //178.00; // valor original
percentual := 10.0 / 100.0; // 10%
valor_maior := valores + (percentual * valores);
valor_menor := valores - (percentual * valores);
EditMaior.Text:= FormatCurr(',##0.00', valor_maior);
EditMenor.Text:= FormatCurr(',##0.00',valor_menor); with qimo do
begin
Qryqimo.close;
Qryqimo.sql.clear;
Qryqimo.SQL.Add('select * from imovel where imovel.valor between '+(Editmaior.Text)+' and '+(Editmenor.Text)+'');
Qryqimo.open;
end;
end;
end.
var
valores, valor_maior, valor_menor, percentual: Currency;
begin
valores := StrToFloat(valor.Text); //178.00; // valor original
percentual := 10.0 / 100.0; // 10%
valor_maior := valores + (percentual * valores);
valor_menor := valores - (percentual * valores);
EditMaior.Text:= FormatCurr(',##0.00', valor_maior);
EditMenor.Text:= FormatCurr(',##0.00',valor_menor); with qimo do
begin
Qryqimo.close;
Qryqimo.sql.clear;
Qryqimo.SQL.Add('select * from imovel where imovel.valor between '+(Editmaior.Text)+' and '+(Editmenor.Text)+'');
Qryqimo.open;
end;
end;
end.
GOSTEI 0
Emerson Nascimento
27/05/2011
procedure T_pesquisa.BitBtn1Click(Sender: TObject);
var
valores, valor_maior, valor_menor, percentual: Currency;
begin
valores := StrToFloat(valor.Text); //178.00; // valor original
percentual := 10.0 / 100.0; // 10% HEIN ???????
valor_maior := valores + (percentual * valores);
valor_menor := valores - (percentual * valores);
EditMaior.Text := FormatCurr(',##0.00', valor_maior);
EditMenor.Text := FormatCurr(',##0.00', valor_menor);
with qimo do
begin
Qryqimo.close;
Qryqimo.sql.clear;
Qryqimo.SQL.Add('select * from imovel ');
Qryqimo.SQL.Add('where valor between '+FloatToStr(valor_menor)+' and '+FloatToStr(valor_maior));
Qryqimo.open;
end;
end;
var
valores, valor_maior, valor_menor, percentual: Currency;
begin
valores := StrToFloat(valor.Text); //178.00; // valor original
percentual := 10.0 / 100.0; // 10% HEIN ???????
valor_maior := valores + (percentual * valores);
valor_menor := valores - (percentual * valores);
EditMaior.Text := FormatCurr(',##0.00', valor_maior);
EditMenor.Text := FormatCurr(',##0.00', valor_menor);
with qimo do
begin
Qryqimo.close;
Qryqimo.sql.clear;
Qryqimo.SQL.Add('select * from imovel ');
Qryqimo.SQL.Add('where valor between '+FloatToStr(valor_menor)+' and '+FloatToStr(valor_maior));
Qryqimo.open;
end;
end;
GOSTEI 0
Valdir Lima
27/05/2011
Olá Emerson,
Muito obrigado, funcionou certinho.
Um abraço.
Valdir Lima
GOSTEI 0