我选择的IP地址段是“172.16.1.128----172.16.1.129,用游标插入,
结果发现只插入了:172.16.1.1,我是按如下代码写的,请问哪里有问题?谢谢。
- SQL code
string ls_1,ls_2,ls_3ls_1=trim(sle_1.text)ls_2=trim(sle_2.text)delete from ip_order;debugbreak()declare c1 cursor forselect ipaddress from ys_ip where ipaddress between :ls_1 and :ls_2;open c1;fetch c1 into :ls_3;do while sqlca.sqlcode=0 insert into ip_order (ip) values(:ls_3); messagebox("err",sqlca.sqlerrtext) fetch c1 into :ls_3;loop
------解决方案--------------------
long li_1,li_2
string ls_1,ls_2,ls_3
ls_1=trim(sle_1.text)
ls_2=trim(sle_2.text)
li_1=mid(lastpos(ls_1,'.')+1,len(ls_1)) //最后'.' 后面的IP值转为数值型
li_2=mid(lastpos(ls_2,'.')+1,len(ls_1))
where reverse(substring(reverse( ipaddress ),1,CHARINDEX('.',reverse( ipaddress ))-1)) between :li_1 and :li_2;
------解决方案--------------------
或者(彻底转换 ):
cast( reverse(substring(reverse('172.16.1.128'),1,CHARINDEX('.',reverse('172.16.1.128'))-1)) as integer) between :li_1 and :li_2;