[ 
http://issues.apache.org/jira/browse/DERBY-277?page=comments#action_12312794 ] 

Peter Haighton commented on DERBY-277:
--------------------------------------

Hi,

Here is the Schema,

CREATE TABLE NA
   (
         NAID BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 
1) CONSTRAINT NA_PK PRIMARY KEY NOT NULL,
         description VARCHAR (4096),
         naType INT
   );

CREATE TABLE NAE
   (
         NAEID BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 
1) CONSTRAINT NAE_PK PRIMARY KEY NOT NULL,
                 NAID BIGINT NOT NULL,
                 sid BIGINT NOT NULL,
                 fieldName VARCHAR(255),
                 fieldValue VARCHAR(4096),
                 creationTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
   );

CREATE INDEX nae_sid_ndx ON nae(sid);

CREATE TABLE S
   (
      SID BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 100, INCREMENT BY 1) 
NOT NULL CONSTRAINT S_PK PRIMARY KEY,
      emailaddress VARCHAR(4096) NOT NULL CONSTRAINT S_U UNIQUE
   };





> Group By and TRIM do not cooperate with more than 1 'not like' statement
> ------------------------------------------------------------------------
>
>          Key: DERBY-277
>          URL: http://issues.apache.org/jira/browse/DERBY-277
>      Project: Derby
>         Type: Bug
>   Components: SQL
>  Environment: java version "1.3.1_13"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_13-b03)
> Java HotSpot(TM) Client VM (build 1.3.1_13-b03, mixed mode)
> Running on Windows XP
>     Reporter: Peter Haighton
>     Priority: Minor

>
> Performing a select that appends BIGINT and VARCHARs together returns some 
> strange results when mixed in with more than 1 not 'not like' statement.
> An example is as follows:
> SELECT RTRIM(CHAR(na.id))||'_'||fieldname, count(*) FROM na, nae, s WHERE 
> na.type=3 and nae.naid=na.id AND fieldvalue='checked' and s.id=nae.sid and 
> s.emailaddress not like '[EMAIL PROTECTED]' group by na.id,fieldname
> na.id is a primary key BIG INT
> fieldname is a varchar
> returns something like
> 32_challenge_100_0 38 
> 32_challenge_100_1 42 
> 32_challenge_100_2 38 
> 32_challenge_100_3 42 
> 32_challenge_100_6 1 
> 32_challenge_101_0 25 
> 32_challenge_101_1 35 
> 32_challenge_101_2 30 
> 32_challenge_101_3 18
> but adding an extra "and userid not like" statement in such as
> SELECT RTRIM(CHAR(na.id))||'_'||fieldname, count(*) FROM na, nae, s WHERE 
> na.type=3 and nae.naid=na.id AND fieldvalue='checked' and s.id=nae.sid and 
> s.emailaddress not like '[EMAIL PROTECTED]' and s.emailaddress not like 
> '%def.com' group by na.id,fieldname
> I get:
> 32645_challenge_100_0 38 
> 32645_challenge_100_1 42 
> 33399_challenge_100_2 38 
> 33399_challenge_100_3 42 
> 18199_challenge_100_6 1 
> 32645_challenge_101_0 25 
> 32645_challenge_101_1 35 
> 32645_challenge_101_2 30 
> 32645_challenge_101_3 18
> ...
> Notice the number 32 has been changed to a somewhat appearing random number. 
> The problem only occurs when I add the trim at the beginning

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to