ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 /** * <b>方法描述:</b> 数据更新 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-04-17 18:38:42 <br/> * @param poolName 入参|数据源,为空使用默认|{@link java.lang.String} * @param tableName 入参|表名String|{@link java.lang.String} * @param colInfos 入参|列信息JavaList,如:[["COL1",VAL1],["COL2",VAL2]]|{@link com.ylink.ide.trade.runtime.context.JavaList} * @param condition 入参|条件信息JavaList,如:["列","=",值]或者[["列1","=",值1],["列2","<",值2]]|{@link com.ylink.ide.trade.runtime.context.JavaList} * @param commitFlg 入参|提交标识Boolean|{@link boolean} * @param doSource 入参|操作数据源,填空默认操作数据库|{@link java.lang.String} * @param result 出参|影响到的笔数int|{@link int} * @return -1 异常<br/>1 成功<br/> */ @Component(label = "数据更新", style = "判断型", type = "同步组件", comment = "用预编译的方式更新指定条件指定库表的指定列值,条件信息的用法为:[[\"列1\",\"=\",值,\"and\"],[\"列2\",\"=\",值2]] = (列1=值1 and 列2=值2),更新影响的笔数放到list[3]中", version = "1.0.0", deprecated = false, author = "admin", date = "2018-04-17 06:38:42") @InParams(param = { @Param(name = "poolName", comment = "数据源,为空使用默认", type = java.lang.String.class), @Param(name = "tableName", comment = "表名String", type = java.lang.String.class), @Param(name = "colInfos", comment = "列信息JavaList,如:[[\"COL1\",VAL1],[\"COL2\",VAL2]]", type = com.ylink.ide.trade.runtime.context.JavaList.class), @Param(name = "condition", comment = "条件信息JavaList,如:[\"列\",\"=\",值]或者[[\"列1\",\"=\",值1],[\"列2\",\"<\",值2]]", type = com.ylink.ide.trade.runtime.context.JavaList.class), @Param(name = "commitFlg", comment = "提交标识Boolean", type = boolean.class) }) @OutParams(param = { @Param(name = "result", comment = "影响到的笔数int", type = int.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功") }) public static ResultBase P_preparedUpdate(String poolName, String tableName, JavaList colInfos, JavaList condition, boolean commitFlg) { try { return ResultBase.newSuccessResult(JdbcUtil.preparedUpdate( poolName, tableName, colInfos, condition, commitFlg)); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTJ0018", "数据更新 异常:" + AppLog.errorMsg(e)); } } 交易中组件使用方式: ![](https://img.kancloud.cn/ff/39/ff39b283d3d8ba7e73d6658991ee7ca7_1680x1234.png) 数据源的来源为项目的配置文件中的数据源,以及前端页面上的数据源管理列表中添加的数据源 ## 参数说明及示例 表名String:数据库表名,示例: `"sys_user"` 列信息JavaList:给这些字段更新值,需要填入集合,示例: `[["name","张三"],["age",39]]` 条件信息JavaList:更新条件集合,示例: `["id","=",3] 或者 [["age","=","28"],["name","=","李四"]]` 提交标识Boolean:是否进行数据库提交,示例: `true` 影响到的笔数int:更新了多少条数据,示例: `__INNER__["num"]` > 注意:填写值如果是String字符串,则需要在前后加上英文双引号"",如果是数字或者boolean值,则不需要