当前位置: 代码迷 >> PB >> pb怎么用like '%%'
  详细解决方案

pb怎么用like '%%'

热度:111   发布时间:2016-04-29 09:08:54.0
pb如何用like '%%'
pl/sql执行
select count(goodsid) from pub_goods where goodsname like '%头孢拉定%';
有10条记录

w_test中一个按钮

string ls_name
long ll_flag
ls_name='头孢拉定'
select count(goodsid) into :ll_flag from pub_goods where goodsname like '%:ls_name%';
messagebox("提示",ll_flag)

结果为0

如果改为 goodsname like :ls_name和goodsname=:ls_name结果一样
怎么改才好呢?

附第一个问题:

w_test有一freeform风格dw_1,向其添加一个按钮b_1
如何操作b_1事件
想实现点击b_1就打开窗口w_test2  


------解决方案--------------------
楼主的这段代码有问题

string ls_name
long ll_flag
ls_name='头孢拉定'
select count(goodsid) into :ll_flag from pub_goods where goodsname like '%:ls_name%';

可以改成

string ls_name
long ll_flag
ls_name='%头孢拉定%'
select count(goodsid) into :ll_flag from pub_goods where goodsname like :ls_name;

------解决方案--------------------
探讨
附第一个问题:

w_test有一freeform风格dw_1,向其添加一个按钮b_1
如何操作b_1事件
想实现点击b_1就打开窗口w_test2

------解决方案--------------------
你的代码写错了。
应该这样写:

string ls_name
long ll_flag
ls_name='头孢拉定'
select count(goodsid) into :ll_flag from pub_goods where goodsname like '%'||:ls_name||'%';
messagebox("提示",ll_flag)

这样就可以了。

因为你要是这样写like '%:ls_name%',
意思就是把like '%:ls_name%'当成了整个查询的字符串。所以肯定就错了。
  相关解决方案