谁用过这样的语句,答对者高分!(再现等待)

delphiyesgood 2003-05-15 02:45:01
with adozbcx do
begin
close;
sql.Clear;
sql.Add('update zzlr set zzdf=case when zzwc>='''+floattostr(ha)+''' then zzdf=5*100*zzqz when zzwc<'''+floattostr(ha)+''' and zzwc>='''+floattostr(jh)+''' then zzdf=4*100*zzqz when zzwc<'''+floattostr(jh)+''' and zzwc>='''+floattostr(yb)+''' then zzdf=3*100*zzqz');
sql.Add('zzwc<'''+floattostr(yb)+''' and zzwc>='''+floattostr(jc)+''' then zzdf=2*100*zzqz when zzwc<'''+floattostr(jc)+''' and zzwc>='''+floattostr(zc)+''' then zzdf=100*zzqz when zzwc=0 then zzdf=0');
prepared;
showmessage(sql.Text);
open;
在程序运行中报 select 第一行=附近语法错误。第一次在 delphi中使用 update set when then 语句,请高手指点,困惑中........
...全文
31 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
egg629 2003-05-15
  • 打赏
  • 举报
回复
检查前面的过程
delphiyesgood 2003-05-15
  • 打赏
  • 举报
回复
全都加上了,可还是报第一行=附近语法错误,这到底为什么?
yoki 2003-05-15
  • 打赏
  • 举报
回复
可能你最后面丢了一个end
yoki 2003-05-15
  • 打赏
  • 举报
回复
加上括号、when的同时后面还要加 end
delphiyesgood 2003-05-15
  • 打赏
  • 举报
回复
to:tj_dns(愉快的登山者)
加上括号、when依然报同样的错误,update set when then 在delphi中能实现吗?谢谢!
happydreamer 2003-05-15
  • 打赏
  • 举报
回复
sql.Add('update zzlr set zzdf=
(case when zzwc>='''+floattostr(ha)+''' then zzdf=5*100*zzqz
when zzwc<'''+floattostr(ha)+''' and zzwc>='''+floattostr(jh)+''' then zzdf=4*100*zzqz
when zzwc<'''+floattostr(jh)+''' and zzwc>='''+floattostr(yb)+''' then zzdf=3*100*zzqz');

sql.Add( when 这里你少了一个when

'zzwc<'''+floattostr(yb)+''' and zzwc>='''+floattostr(jc)+''' then zzdf=2*100*zzqz
when zzwc<'''+floattostr(jc)+''' and zzwc>='''+floattostr(zc)+''' then zzdf=100*zzqz
when zzwc=0 then zzdf=0' end)');



愉快的登山者 2003-05-15
  • 打赏
  • 举报
回复
sql.Add('update zzlr set zzdf=(case when zzwc>='''+floattostr(ha)+''' then zzdf=5*100*zzqz when zzwc<'''+floattostr(ha)+''' and zzwc>='''+floattostr(jh)+''' then zzdf=4*100*zzqz when zzwc<'''+floattostr(jh)+''' and zzwc>='''+floattostr(yb)+''' then zzdf=3*100*zzqz');
sql.Add(' when zzwc<'''+floattostr(yb)+''' and zzwc>='''+floattostr(jc)+''' then zzdf=2*100*zzqz when zzwc<'''+floattostr(jc)+''' and zzwc>='''+floattostr(zc)+''' then zzdf=100*zzqz when zzwc=0 then zzdf=0 end)');

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧