Adaptive Server Anywhere是PB自带的一个数据库, 早期做的一些项目是使用ASA8做为网络数据库的,今天客户发现在product的description方面有问题. 数据表docdesc结构很简单
autoid unsigned int autoincrement
doc_no varchar(10)
product_no varchar(15)
filecode varchar(2)
kind varchar(4)
value varchar(50)
select * from docdesc where doc_no='INV09/053'
可以看到要查询的数在结果集中
select * from docdesc where product_no='7826-21'
可以看到要查询的数据在结果集中
但是
select * from docdesc where doc_no='INV09/053' and product_no='7826-21'
就是没有返回要查询的结果.
使用
select * from docdesc where doc_no like 'INV09/053%' and product_no='7826-21'
或
select * from docdesc where doc_no like 'INV09/053' and product_no like '7826-21%'
都可以看到结果.
列奇怪的是这张invoice INV09/053的其它product是正常的,比如
select * from docdesc where doc_no='INV09/053' and product_no='7826-45'
select * from docdesc where doc_no='INV09/053' and product_no='7826'
都有结果返回。
尝试把doc_no及product no 都手工update.
update docdesc set product_no='7826-21', doc_no='INV09/053' where doc_no like 'INV09/053%' and product_no='7826-21'
还是不行。
再试着重新生成这张INV09/053,都不行, 只好把数据库从客户的服务器下载到本地测试了。
后来,发现这张表的索引是doc_no + product_no, 于是,尝试把这个索引删除,只建立一个索引
一个是doc_no的,不再对product_no索引,结果,问题解决。
虽然解决了问题,可具体原因还是没法判断出来,可能是索引损坏了,也许是ASA这个产品的BUG。