主要是我不太懂Delphi里SQL怎么写
select a.cust_id,b.cust_name,sum(time1),sum(amount/100)
from dc_callinginfo_stl a, dc_cust_stl b
where a.cust_id in ('00006','00007','00008','00009','00022','031523','031529','031530','031533','031541')
and a.stop_time>=trunc(sysdate-1)
and a.stop_time<trunc(sysdate)
and b.cust_id = a.cust_id
group by a.cust_id,b.cust_name;
在PB6上运行没问题
我要写在Delphi的Adodataset.commandtext:='';里
大家看看怎么写啊?我写不太好,总出错!
select a.cust_id,b.cust_name,sum(time1),sum(amount/100)
from dc_callinginfo_stl a, dc_cust_stl b
where a.cust_id in ('00006','00007','00008','00009','00022','031523','031529','031530','031533','031541')
and a.stop_time>=trunc(sysdate-1)
and a.stop_time<trunc(sysdate)
and b.cust_id = a.cust_id
group by a.cust_id,b.cust_name;
在PB6上运行没问题
我要写在Delphi的Adodataset.commandtext:='';里
大家看看怎么写啊?我写不太好,总出错!
Adodataset.commandtext:=' select a.cust_id,b.cust_name,sum(time1),sum(amount/100) '+
' from dc_callinginfo_stl a, dc_cust_stl b '+
' where a.cust_id in (''00006'',''00007'',''00008'',''00009'',''00022'',''031523'',''031529'',''031530'',''031533'',''031541'') '+
' and a.stop_time>=trunc(sysdate-1) '+
' and a.stop_time<trunc(sysdate) ' +
' and b.cust_id = a.cust_id ' +
' group by a.cust_id,b.cust_name ';
比如:SQL语句为 SELECT * FROM Table1 WHERE Name='test';
那么在DELPHI中就是:SELECT * FROM Table1 WHERE Name=''test'';
然后再把这个字符串赋给某个变量:strSQL := 'SELECT * FROM Table1 WHERE Name=''test''';
就正确了!
我很少重新启行的都一次写完
+' from dc_callinginfo_stl a, dc_cust_stl b'
+' where a.cust_id in (:a1,:a2)'
+' and a.stop_time>=trunc(sysdate-1)'
+' and a.stop_time<trunc(sysdate)'
+' and b.cust_id = a.cust_id'
+' group by a.cust_id,b.cust_name';
adodataset1.Parameters[0].Value:='00006';
adodataset1.Parameters[1].Value:='00007';这样写为什么报错啊?谢谢