有一条sql语句在DELPHI中不能执行 ( 积分: 100 )

  • 主题发起人 主题发起人 wjqzzzz
  • 开始时间 开始时间
W

wjqzzzz

Unregistered / Unconfirmed
GUEST, unregistred user!
在ORACLE环境下可以执行成功,但加入到DELPHI中后,总是编译出错,怎样才能正常执行呀!
语句如下:
select PPDGY0302 商品编码,dg0102 商品名称,sum(PPDGY0304) 帐存数量,sum(PPDGY0305) 帐存金额 ,sum(PPDGY0306) 实盘数量,sum(PPDGY0307) 实盘金额,sum(PPDGY0306-PPDGY0304) 盈亏数量,
sum(PPDGY0307-PPDGY0305) 盈亏金额
from PPDGY003,dg001
where ppdgy0301 between 161 and 221
and dg0101=ppdgy0302
and ppdgy0302 like '24%'
having sum(PPDGY0307-PPDGY0305)<>0
group by PPDGY0302,dg0102
order by sum(PPDGY0307-PPDGY0305)
 
在ORACLE环境下可以执行成功,但加入到DELPHI中后,总是编译出错,怎样才能正常执行呀!
语句如下:
select PPDGY0302 商品编码,dg0102 商品名称,sum(PPDGY0304) 帐存数量,sum(PPDGY0305) 帐存金额 ,sum(PPDGY0306) 实盘数量,sum(PPDGY0307) 实盘金额,sum(PPDGY0306-PPDGY0304) 盈亏数量,
sum(PPDGY0307-PPDGY0305) 盈亏金额
from PPDGY003,dg001
where ppdgy0301 between 161 and 221
and dg0101=ppdgy0302
and ppdgy0302 like '24%'
having sum(PPDGY0307-PPDGY0305)<>0
group by PPDGY0302,dg0102
order by sum(PPDGY0307-PPDGY0305)
 
肯定是你的'单引号在转发的过程中出错了。。。
 
SQL:='select PPDGY0302 商品编码,dg0102 商品名称,sum(PPDGY0304) 帐存数量,'
+' sum(PPDGY0305) 帐存金额 ,sum(PPDGY0306) 实盘数量,sum(PPDGY0307) 实盘金额,'
+' sum(PPDGY0306-PPDGY0304) 盈亏数量,'
+' sum(PPDGY0307-PPDGY0305) 盈亏金额 '
+' from PPDGY003,dg001'
+' where ppdgy0301 between 161 and 221'
+' and dg0101=ppdgy0302'
+' and ppdgy0302 like ''24%'''
+' having sum(PPDGY0307-PPDGY0305)<>0'
+' group by PPDGY0302,dg0102'
+' order by sum(PPDGY0307-PPDGY0305) ';
 
多人接受答案了。
 
后退
顶部