【问题标题】:if condition and counter increment如果条件和计数器递增
【发布时间】:2011-05-20 20:59:05
【问题描述】:

这个 if 条件有什么问题?

  if ((@rent_amt_h <> '0.000') or (@house_payment_amt_h <> '0.000') or (@insurance_amt_h <> '0.000')or (@property_taxes_amt_h <> '0.000') or  (@gas_amt_u <> '0.000') or (@elec_amt_u <> '0.000') or (@otherfuel_amt_u <> '0.000') or (@Trash_Collection_amt_u <> '0.000') or (@Sewerage_amt_u <> '0.000') or (@Telephone_amt_u <> '0.000') or (@water_amt_u <> '0.000') or (@other_house_amt_h <> '0.000') or (@other_amt_u <> '0.000') or (@total_u <> '0.000'))

                           begin
                 SET @APPSHELTER_COUNT  =  (select Count(APP_ID) FROM ext_app_group_other_expenses (nolock)  WHERE APP_ID = @App_Id )
               end
               else
               begin
                 SET @APPSHELTER_COUNT  =  0
               end

它会增加@APPSHELTER_COUNT 的值,即使 if 条件中的值为零!。它从不将值设置为 0?

感谢您的帮助。

【问题讨论】:

  • 您的 if 语句中有 14 个子句 - 难以阅读且无法维护

标签: if-statement counter conditional-statements increment


【解决方案1】:

那是什么语言?无论如何,感觉就像您正在将数字与字符串进行比较。尝试删除零周围的引号。例如@rent_amt_h &lt;&gt; 0 而不是@rent_amt_h &lt;&gt; '0.000'。另外,如果那是一些 SQL,请确保您正确处理 NULL,因为 NULL != 0

【讨论】:

  • @userstackoverflow: 随时:)
猜你喜欢
  • 2015-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多