A-A+

一个还不错的SQL封装

2008年11月25日 编程开发 暂无评论 阅读 1 次

  public String zhpk_sql_2(String BA_ID,BGBAActionForm form)
   StringBuffer sb = new StringBuffer("Update NTLJ_ZHPK a set ");
    sb = sb.append("ZT='9'");

    sb = sb.append(isNullNotUpdate("Name",form.getB_name()));
    sb = sb.append(isNullNotUpdate("lxdh",form.getB_lxdh()));
    sb = sb.append(isNullNotUpdate("zsdz",form.getB_zsdz()));
    sb = sb.append(isNullNotUpdate("zzdz",form.getB_zzdz()));
    sb = sb.append(isNullNotUpdate("Yzbm1",form.getB_yzbm1()));
    sb = sb.append(isNullNotUpdate("yzbm2",form.getB_yzbm2()));
    sb = sb.append(isNullNotUpdate("sfzmc",form.getB_sfzmc()));
    sb = sb.append(isNullNotUpdate("sfzhm",form.getB_sfzhm()));
    sb = sb.append(isNullNotUpdate("jzzmc",form.getB_jzzmc()));
    sb = sb.append(isNullNotUpdate("jzzhm",form.getB_jzzhm()));
    sb = sb.append(" where A.ID=(select ZID from Ntlj_Bgbab b where  b.id = '"+BA_ID+"')");
     return sb.toString();
  }

public String isNullNotUpdate(String field,String value)
{
    if(value== null || value.equals(""))
{
      return "";
    }
else
{
      return ("," + field + "='" + value + "'");
    }
  }

标签:

给我留言

Copyright © 浩然东方 保留所有权利.   Theme  Ality 07032740

用户登录