Fórum SQLQuery #232136
13/05/2004
0
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
Curtir tópico
+ 0Posts
13/05/2004
Rômulo Barros
Gostei + 0
14/05/2004
Glauco Filoco
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.
Gostei + 0
17/05/2004
Cebadios
Gostei + 0
18/05/2004
Glauco Filoco
Obrigado pela dica, eu já estava imaginando que
era isso mesmo.
Abraço,
GLAUCO
Gostei + 0
18/05/2004
Cebadios
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)