我写了这样查询语句(数据库为oracle)
query.SQL.Text:='select R.*,rowid from its_policeviolation R where :a1 between :a2 and :a3';
query.ParamByName('a1').Value:='SJ';
query.ParamByName('a2').AsDate:=strtodate('2006-2-12');
query.ParamByName('a3').AsDate:=strtodate('2006-6-12');
query.Open;
提示 "ora-01858 a non-numeric character was found where a numeric was excepted"
上述语句有错吗?
query.SQL.Text:='select R.*,rowid from its_policeviolation R where :a1 between :a2 and :a3';
query.ParamByName('a1').Value:='SJ';
query.ParamByName('a2').AsDate:=strtodate('2006-2-12');
query.ParamByName('a3').AsDate:=strtodate('2006-6-12');
query.Open;
提示 "ora-01858 a non-numeric character was found where a numeric was excepted"
上述语句有错吗?
begin
Close;
SQL.Clear;
SQL.Add('select * from Alarm_master_online where SJ between :p2 and :p3');
Parameters.ParamByName('p2').value :=strTodate('2006-02-10');
Parameters.ParamByName('p3').Value :=strTodate('2006-02-28');
Open;
end;
时间字段怎么设我也没搞定。帮你顶!
query.ParamByName('a1').Value:='SJ';
query.ParamByName('a2').AsDate:=strtodate('2006-2-12');
query.ParamByName('a3').AsDate:=strtodate('2006-6-12');
query.Open;
提示 "ora-01858 a non-numeric character was found where a numeric was excepted"
===================================
从以上提示信息来看, 估计是你其中的一个字段的类型搞错了, 大有可能问题出现在以下两处:
'select R.*,rowid from its_policeviolation R where :a1 between :a2 and :a3';
^^^^^ ^^^
query.ParamByName('a1').Value:='SJ';//这不是数字型的值吧?
query.ParamByName('a2').AsDate:=strtodate('2006-2-12');
query.ParamByName('a3').AsDate:=strtodate('2006-6-12');
query.Open;
提示 "ora-01858 a non-numeric character was found where a numeric was excepted"
上述语句有错吗?
BEGIN
query.SQL.Text:='select R.*,rowid from its_policeviolation R where '
+ SFIELDNAME + ' between :a2 and :a3';query.ParamByName('a2').AsDate:=strtodate('2006-2-12');
query.ParamByName('a3').AsDate:=strtodate('2006-6-12');
query.Open;
你用楼上的方法,如果不行的话,大概需要使用group by