Subject equal not getting results
Author Ernesto Cullen
Hi all,
I have the following tables structures defined:

CREATE TABLE DATOSUNO (
IDDATOUNO INTEGER NOT NULL,
CODIGO VARCHAR(20) NOT NULL,
FECHAPEDIDO DATE,
CAJA VARCHAR(10),
CANTIDAD NUMERIC(18,2),
LOTE VARCHAR(10),
ARCHIVO VARCHAR(80),
GRUPO VARCHAR(10),
CONTRATO VARCHAR(20) NOT NULL,
CONSTRAINT DATOSUNO_PK PRIMARY KEY (IDDATOUNO)
);

CREATE UNIQUE INDEX DATOSUNO_PK ON DATOSOTIS(IDDATOUNO);
CREATE UNIQUE INDEX IXCONTRATOCODIGO_UNO ON DATOSUNO(CONTRATO,CODIGO);


CREATE TABLE DATOSTERMINALES (
IDDATOTERMINAL INTEGER NOT NULL,
CODIGO VARCHAR(20) NOT NULL,
FECHARECEPCION DATE,
GRUPO VARCHAR(10),
CANTIDAD NUMERIC(18,2),
LOTE VARCHAR(10),
NROTERMINAL INTEGER,
CONTRATO VARCHAR(20) NOT NULL,
CONSTRAINT DATOTERMINAL_PK PRIMARY KEY (IDDATOTERMINAL)
);

CREATE UNIQUE INDEX DATOTERMINAL_PK ON DATOSTERMINALES(IDDATOTERMINAL);
CREATE INDEX IXCONTRATOCODIGO_TERM ON DATOSTERMINALES(CONTRATO,CODIGO);


I have many records in DatosUno with Contrato='60NSL305' (for example, the
same happens with any value). If I issue

select * from DatosUno where Contrato='60NSL305'

then it returns several records, correctly.

But now, I too have many records in DatosTerminales with
Contrato='60NSL305', but if I ask for

select * from DatosTerminales where Contrato='60NSL305'

it returns nothing. But if I ask

select * from DatosTerminales where Contrato like '60NSL305%'

then it returns all rows with Contrato='60NSL305'.

Any idea why is this happening? I have tried with FB 1.0.3 and FB 1.5 RC6,
same result. I dropped the index IXCONTRATOCODIGO_TERM, same result...
I need to get the records from an outer join on both tables, like this

select o.Contrato, o.FechaPedido, o.Caja, o.Codigo, o.Cantidad as
CantPedida, o.Lote,
t.Cantidad as CantRecibida, t.FechaRecepcion, t.NroTerminal, o.Grupo
from DatosUno o
left join DatosTerminales t on (o.Contrato=t.Contrato and
o.Codigo=t.Codigo)

but it gets all the data from DatosUno, nothing from DatosTerminales.

Thanks for any help,


Ernesto Cullen
ecullen@...
http://www.infoback.com.ar/buhardilla
Paraná, Entre Ríos
Argentina