关于perl编写的查询问题
我用Access建了个表,名为scompany。其中元素为company,postcode,
addr,job_num,scale,都为文本类型。其查询语句为:
$num='10001';
$stmt = "select scale,postcode, addr,company
from scompany
where job_num ='10001';";
$rc = $db->Sql($stmt);
结果正确,但将where中的语句改成: job_num =$num,其余都不变,则出现如下错误
提示:Error: [-3030] [1] [0] "[Microsoft][ODBC Microsoft Access 驱动程序] 标准表达式中数据类型不匹配。"
这是为什么?恳请指导!
thanks!
问题点数:50、回复次数:4Top
1 楼ZPoint(别理我)回复于 2000-06-17 14:04:00 得分 0
you can try it:
$num='10001';
$stmt = "select scale,postcode, addr,company
from scompany
where job_num ='$num';";
$rc = $db->Sql($stmt);
if you type: job_num=$num then it output is job_num=10001,
and job_num='$num' the output is job_num='10001.
Top
2 楼wsh218()回复于 2000-06-26 12:23:00 得分 0
谢谢ZPoint的回复,我试了一下,他的解决是正确的。问
题的确出在赋值。呵呵,thank you!
Top
3 楼ZPoint(别理我)回复于 2000-06-30 16:05:00 得分 50
给分!!
~@~Top
4 楼flyby(小维龙)回复于 2000-09-09 09:31:00 得分 0
如果变量是字符串:job_num='$num'
如果变量非字符串:job-num=$num
写SQL语句是一定要记住呀
问题解决了
就加分吧 反正分数也收不回了!
:-)Top




