Subject Re: [firebird-support] equal not getting results
Author Martijn Tonies
Hi,

> 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);

-> Why are you creating a unique index? You already have a Primary Key
Constraint defined on IDDATOUNO - which automatically creates an index.

> 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);


-> Same here.

> 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'.

I have trouble believing this - are you sure there are not trialing,
but perhaps unview-able, characters?

> Any idea why is this happening? I have tried with FB 1.0.3 and FB 1.5 RC6,


With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird & MS SQL Server.
Upscene Productions
http://www.upscene.com