Fórum SQLQuery #232136

13/05/2004

0

ola Pessoal,

Alguém por acaso já se deparou com a mensagem abaixo ao
tentar abrir uma query na DBExpress ( uso o SQLQuery via código ):

[b:0d9c32da72]Unable to determine field names for ¬s´[/b:0d9c32da72]

Se alguem já viu e se lembrar, poderia me dar uma dica ?

É que tenho uma query aqui que roda normalmente no ambiente do
banco de dados Oracle, mas ao tentar executá-la, de forma dinamica,
dentro do código, dá a mensagem acima.

Obrigado a quem puder ajudar.
GLAUCO
:?:


Glauco Filoco

Glauco Filoco

Responder

Posts

13/05/2004

Rômulo Barros

Provavelmente vc deve esta utilizando o método FORMAT() incorretamente. Também utilizo Oracle (8i) e trabalho sempre com TsqlQuery de forma dinamica. Poste aqui os comandos SQL para analisarmos !!!! :roll:


Responder

Gostei + 0

14/05/2004

Glauco Filoco

Rômulo,

Obrigado por me responder. Olha, abaixo a query, que funciona no SQLPlus, mas dentro do código no Delphi não (a aplicação é Intraweb):

[b:9d7dcc25b3]select
t.instituicao, t.nsuservcel, t.dthoraservcel, t.nsuinstituicao, t.dthorainstituicao,
t.telefone, t.valor, t.estadotrn, t.codresp, t.idterm, t.cep, t.tipoterminal, p.id,
p.descricao, e.id, e.descricao, e.categoria, i.id, i.descricao, c.descricao, t.filial,
o.descricao, o.id
from
transacao t, tipoterminal p, estadotrn e, instituicao i, categoriaestadotrn c, filial o
where
((t.dthoraservcel >= ´01/02/2004´) and
(c.descricao = ´Efetuada´) and
(i.descricao = ´Banrisul´) and
(p.descricao = ´ATM´) and
(o.descricao = ´Acre´)) and
(t.instituicao = i.id) and
(t.estadotrn = e.id) and
(t.tipoterminal = p.id) and
(e.categoria = c.id) and
(t.Filial = o.id)
order by t.dthoraservcel[/b:9d7dcc25b3]

Agora transcrevo como ela está no meu código:


[b:9d7dcc25b3]strSql := ´select t.instituicao, t.nsuservcel, t.dthoraservcel, t.nsuinstituicao, ´ +
´t.dthorainstituicao, t.telefone, t.valor, t.estadotrn, t.codresp, ´ +
´t.idterm, t.cep, t.tipoterminal, p.id, p.descricao, e.id, ´ +
´e.descricao, e.categoria, i.id, i.descricao, ´ +
´c.descricao, t.filial, o.descricao, o.id ´ +
´from transacao t, tipoterminal p, estadotrn e, ´ +
´instituicao i, categoriaestadotrn c, filial o ´ +
´where ´;

strSql := strSql + ´((t.dthoraservcel >= ´ + QuotedStr(DataInicial.Text) + ´)´;

if Statustransacao.ItemIndex > 0 then
begin
strSql := strSql + ´ and (c.descricao = ´ + QuotedStr(StatusTransacao.Items[StatusTransacao.ItemIndex]) + ´)´;
end;

if Instituicao.ItemIndex > 0 then
begin
strSql := strSql + ´ and (i.descricao = ´ + QuotedStr(Instituicao.Items[Instituicao.ItemIndex]) + ´)´;
end;

if TipoTerminal.ItemIndex > 0 then
begin
strSql := strSql + ´ and (p.descricao = ´ + QuotedStr(TipoTerminal.Items[TipoTerminal.ItemIndex]) + ´)´;
end;

if Filial.ItemIndex > 0 then
begin
strSql := strSql + ´ and (o.descricao = ´ + QuotedStr(Filial.Items[Filial.ItemIndex]) + ´))´;
end;

strSql := strSql + ´ and (t.instituicao = i.id) and ´ +
´(t.estadotrn = e.id) and (t.tipoterminal = p.id) ´ +
´and (e.categoria = c.id) and (t.Filial = o.id)´+
´ order by t.dthoraservcel´;

ExecutaSql(trim(strSql), dataHoraI, dataHoraF);[/b:9d7dcc25b3]

Dentro da procedure ExecutaSql faço o seguinte:


[b:9d7dcc25b3]var
lin, // linha do grid
col, // coluna do grid
ctEfet, // contador transações efetivadas
ctNaoConcl: integer; // contador transações não concluídas
valEfet, // valor transações efetivadas
valNaoConcl, // valor transações não concluídas
ValorAux: double; // auxuliar para formatar valor como x.xxx,xx
telaux, dtHrTmp: string; // data e hora no formato do BD

begin
ctEfet := 0; ctNaoConcl := 0;
valEfet := 0; valNaoConcl := 0;
lin := 0; col := 0;

if not SQLConnection1.connected then
try
SQLConnection1.connected := true;
except
WebApplication.ShowMessage(´Erro ao acessar banco de dados.´);
SQLConnection1.connected := false;
exit;
end;

SQLDataSet1.Close;
SQLDataSet1.CommandText := ´´;
SQLDataSet1.CommandText := strSql;

try
SQLDataSet1.Open;
except
WebApplication.ShowMessage(´Erro ao acessar banco de dados.´);
SQLConnection1.connected := false;
LimpaErro;
exit;
end;

if SQLDataSet1.RecordCount = 0 then[/b:9d7dcc25b3]
( o erro acontece na linha imediatamente acima )



OBRIGADÃO,
GLAUCO.


Responder

Gostei + 0

17/05/2004

Cebadios

Glauco, infelizmente deparei com esse problema em um projeto meu, e cheguei a conclusão que o Intraweb não suporta O evento de Recordcount da Query, onde tive que bolar um macete para suprir esse bug.


Responder

Gostei + 0

18/05/2004

Glauco Filoco

Cebadios,

Obrigado pela dica, eu já estava imaginando que
era isso mesmo.

Abraço,
GLAUCO


Responder

Gostei + 0

18/05/2004

Cebadios

Sabe qual a maneira vc pode fazer, é efetuando um selec count, onde se retornar valor > 0 vc executa a rotina.


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar