Problem with query on Firebird 2.5
Posted: Fri 03 Sep 2010 14:40
I have a table with the following schema in a Firebird 2.5 DATEbase with the connection being made by your DevArtInterbase driver (dbExpIDA.dll).
CREATE TABLE EFIN_ORDEMSERVICO (
CDORDEMSERVICO INTEGER NOT NULL,
NURECIBOOS INTEGER,
NUORDEMSERVICO INTEGER,
NMFAVORECIDO VARCHAR(100),
DTORDEMSERVICO TIMESTAMP,
FLATIVO CHAR(1) NOT NULL,
DEMOTIVOCANCELAMENTO VARCHAR(150),
VLTOTALRECIBOBRUTO NUMERIC(15,2),
VLDESCONTO NUMERIC(15,2),
VLTOTALRECIBOLIQ NUMERIC(15,2),
VLTOTALCONTABIL NUMERIC(15,2),
VLTOTALREEMBOLSO NUMERIC(15,2),
VLTOTALTAXAS NUMERIC(15,2),
DTPAGTO DATE,
FLISENTO CHAR(1),
CDSETOR INTEGER,
CDCORRENTISTA INTEGER,
DELOGINDESCONTO VARCHAR(20),
DELOGIN VARCHAR(20),
DTCANCELAMENTO DATE,
DELOGINCANCELAMENTO VARCHAR(20),
DEDESCONTOOS DESCRICAO,
FLDEPOSITOANTECIPADO CHAR(1),
DELOGINALTERACAO VARCHAR(20),
DTALTERACAO TIMESTAMP,
DELOGINPAGTO VARCHAR(20),
DTREGISTROPGTO TIMESTAMP,
VLTOTALVINCULADO NUMERIC(15,2),
FLCOBRARUMTERCO CHAR(1),
FLOSAVULSA CHAR(1)
);
And this SQL is being executed with a ClientDATEset SQLQuery DATESetProvider component set.
select
cdOrdemServico,
nuOrdemServico,
dtPagto as OS_dtPagto,
flIsento as OS_flIsento,
cdCorrentista as OS_Correntista,
cast( DTORDEMSERVICO as Date ) as OS_dtCriacao,
cast( (VLTOTALRECIBOLIQ - VLTOTALVINCULADO ) as numeric(15,2) ) as Saldo
from efin_OrdemServico
where flAtivo = 'S'
and (cdOrdemServico containing '350124')
When I debug this on Delphi (with stop on Delphi exceptions checked), its returns:
Field “cdCorrentista” not found
But, as shown in the DDL above, it exists (and works well both on IbExpert and the Firebird ISQL command line tool)
When I add this line on SQL : “cdCorrentista,” in select list, another error occurs:
Field “flAtivo” not found
But, again, it exists (see DDL).
When I put this line on SQL : “flativo,” in select list, another error occurs:
Field “dtPagto” not found
It’s seems to be a problem with the use of alias on select fields list.
When running the software outside delphi the exception don't happen (it's treated) but it's terrible to debug an application with this problem.
CREATE TABLE EFIN_ORDEMSERVICO (
CDORDEMSERVICO INTEGER NOT NULL,
NURECIBOOS INTEGER,
NUORDEMSERVICO INTEGER,
NMFAVORECIDO VARCHAR(100),
DTORDEMSERVICO TIMESTAMP,
FLATIVO CHAR(1) NOT NULL,
DEMOTIVOCANCELAMENTO VARCHAR(150),
VLTOTALRECIBOBRUTO NUMERIC(15,2),
VLDESCONTO NUMERIC(15,2),
VLTOTALRECIBOLIQ NUMERIC(15,2),
VLTOTALCONTABIL NUMERIC(15,2),
VLTOTALREEMBOLSO NUMERIC(15,2),
VLTOTALTAXAS NUMERIC(15,2),
DTPAGTO DATE,
FLISENTO CHAR(1),
CDSETOR INTEGER,
CDCORRENTISTA INTEGER,
DELOGINDESCONTO VARCHAR(20),
DELOGIN VARCHAR(20),
DTCANCELAMENTO DATE,
DELOGINCANCELAMENTO VARCHAR(20),
DEDESCONTOOS DESCRICAO,
FLDEPOSITOANTECIPADO CHAR(1),
DELOGINALTERACAO VARCHAR(20),
DTALTERACAO TIMESTAMP,
DELOGINPAGTO VARCHAR(20),
DTREGISTROPGTO TIMESTAMP,
VLTOTALVINCULADO NUMERIC(15,2),
FLCOBRARUMTERCO CHAR(1),
FLOSAVULSA CHAR(1)
);
And this SQL is being executed with a ClientDATEset SQLQuery DATESetProvider component set.
select
cdOrdemServico,
nuOrdemServico,
dtPagto as OS_dtPagto,
flIsento as OS_flIsento,
cdCorrentista as OS_Correntista,
cast( DTORDEMSERVICO as Date ) as OS_dtCriacao,
cast( (VLTOTALRECIBOLIQ - VLTOTALVINCULADO ) as numeric(15,2) ) as Saldo
from efin_OrdemServico
where flAtivo = 'S'
and (cdOrdemServico containing '350124')
When I debug this on Delphi (with stop on Delphi exceptions checked), its returns:
Field “cdCorrentista” not found
But, as shown in the DDL above, it exists (and works well both on IbExpert and the Firebird ISQL command line tool)
When I add this line on SQL : “cdCorrentista,” in select list, another error occurs:
Field “flAtivo” not found
But, again, it exists (see DDL).
When I put this line on SQL : “flativo,” in select list, another error occurs:
Field “dtPagto” not found
It’s seems to be a problem with the use of alias on select fields list.
When running the software outside delphi the exception don't happen (it's treated) but it's terrible to debug an application with this problem.