SQL - me bad or parser bad

Robert Brenstein rjb at rz.uni-potsdam.de
Tue Mar 25 16:39:09 CST 2003


Problem:

Valentina selects records that should be excluded. Namely, records 
with non-empty u_canc field are included.

SQL query:

Select r_rid,r_lna,r_fna,r_mna,r_ema,r_tit,a_titl, 
a_cdts,r_fee,u_canc,u_oral From 
abstract2,registration2a,registration2b
Where r_rid = u_rid and a_rid = u_rid and a_cdts < 1046077200 and 
r_fee <> 5  and r_fee <> 6 and u_canc = '' and u_oral = ''
Order by r_lna,r_fna

tables involved:

abstract2
1	a_aid	Short  	 	i
2	a_rid	Short  	 	i
3	a_titl	String [300]	ASCII
4	a_aims	String [750]	ASCII
5	a_meth	String [1000]	ASCII
6	a_resu	String [1000]	ASCII
7	a_cdts	String [20]	ASCII	i
8	a_udts	String [20]	ASCII
9	x_titl	Short
10	x_aims	Short
11	x_meth	Short
12	x_resu	Short
13	x_abst	Short
14	a_uip	String [16]	ASCII
15	a_canc	String [20]	ASCII	i
16	a_lna	String [45]	ASCII
17	a_fna	String [45]	ASCII
18	x_caut	Short

registration2a
1	r_rid	Short  	 	i
2	r_uip	String [16]	ASCII
3	r_tit	String [1]	ASCII
4	r_lna	String [45]	ASCII	i
5	r_fna	String [45]	ASCII	i
6	r_mna	String [15]	ASCII
7	r_aff	String [100]	ASCII
8	r_dpu	String [60]	ASCII
9	r_ema	String [99]	ASCII	i
10	r_tel	String [25]	ASCII
11	r_fax	String [25]	ASCII
12	r_fee	String [1]	ASCII	i
13	r_ban	String [8]	ASCII
14	r_pay	String [1]	ASCII
15	r_ccs	String [1]	ASCII
16	r_ccn	String [30]	ASCII
17	r_cce	String [10]	ASCII
18	r_cse	String [3]	ASCII
19	r_chn	String [60]	ASCII
20	r_bad	String [200]	ASCII
21	r_roo	String [1]	ASCII
22	r_smo	String [1]	ASCII
23	r_hd0	String [8]	ASCII
24	r_hd1	String [8]	ASCII
25	r_hd2	String [8]	ASCII
26	r_hd3	String [8]	ASCII
27	r_hd4	String [8]	ASCII
28	r_hot	String [100]	ASCII
29	r_shr	String [45]	ASCII
30	r_had	String [200]	ASCII
31	r_con	String [1]	ASCII
32	r_acc	String [20]	ASCII
33	r_shu	String [1]	ASCII
34	r_di1	String [1]	ASCII	i
35	r_di2	String [100]	ASCII
36	r_rem	String [500]	ASCII	i
37	r_cdts	String [20]	ASCII	i
38	r_udts	String [20]	ASCII	i
39	r_bn2	String [8]	ASCII
40	r_psw	String [25]	ASCII
41	r_twn	String [45]	ASCII
42	r_str	String [100]	ASCII
43	r_zip	String [15]	ASCII
44	r_ctr	String [45]	ASCII
45	r_kid	Short

registration2b
1	u_accp	String [20]	ASCII
2	u_oral	String [20]	ASCII	i
3	u_rid	Short  	 	i
4	u_aid	Short  	 	i
5	u_mtch	String [200]	ASCII	i w
6	u_rcod	String [16]	ASCII
7	u_nots	VarChar [2048]	ASCII	i
8	u_ndts	String [10]	ASCII
9	u_hots	VarChar [1024]	ASCII
10	u_rdts	String [10]	ASCII
11	u_canc	String [20]	ASCII	i
12	u_refd	String [20]	ASCII
13	u_rfdt	String [20]	ASCII
14	u_hdat	String [45]	ASCII
15	u_hfax	String [20]	ASCII
16	u_crcv	String [20]	ASCII
17	u_cbok	String [20]	ASCII
18	u_cver	String [20]	ASCII
19	u_ctot	Short
20	u_wait	String [20]	ASCII
21	u_cdts	String [20]	ASCII
22	u_udts	String [20]	ASCII
23	u_lock	Short
24	u_ptot	String [25]	ASCII
25	u_acod	String [16]	ASCII

Discussion:

The order of "where" items is like Ruslan recommended in the past: 
links first, then conditions grouped by table. I tried changing the 
order, putting quotes. However, no matter what order I use, I get 
records with either non-empty u_canc or non-empty u_oral whichever is 
first in the Where clause!

When is the new and improved SQL parser coming?

Robert


More information about the Valentina mailing list