jquery - 更新数据库时出错!表或视图不存在
问题描述
我有这个查询
<update id="updateRow">
update
ROW
set
DISPLAY_ID = #{displayId}
<where>
<include refid="rowCriteria" />
</where>
</update>
<sql id="rowCriteria">
<if test="criteria.displayId} != null">
DISPLAY_ID=#{criteria.displayId}
</if>
<if test="criteria.id != null">
and ID=#{criteria.id}
</if>
</sql>
以及在哪里执行
Preparing: update ROW set DISPLAY_ID = ? WHERE ID=?
Parameters: 72312(Long), 72991(Long)
我得到这个错误
该错误可能涉及defaultParameterMap
设置参数时出错
SQL:更新 ROW 集 DISPLAY_ID = ? 在哪里 ID =?
原因:java.sql.SQLSyntaxErrorException:ORA-00942:表或视图不存在
但是如果我从标准 ID 中删除“和”
<sql id="rowCriteria">
<if test="criteria.displayId} != null">
DISPLAY_ID=#{criteria.displayId}
</if>
<if test="criteria.id != null">
ID=#{criteria.id}
</if>
</sql>
查询运行正确并执行更新
我的问题是,如果我在标准中有and 键,为什么有时更新会正确运行,但有时会出现错误?
解决方案
两件事情:
删除
}
多余的。在每个条件前加上
AND
. < where > 标签将始终删除第一个标签。AND DISPLAY_ID=#{criteria.displayId} 和 ID=#{criteria.id}
推荐阅读
- javascript - reactJS中如何管理多标签注销?
- git - Phabricator 错误:解压失败:Git 推送时无法创建临时对象目录?
- javascript - 在 Firebase 上查找用户 ID
- visual-studio-code - 从 VS 代码中的 Activity Bar 中删除垂直指示线
- xml - 如何通过键号替换两个文件之间的文本
- javascript - 如何在某些条件下使用 Angular 8 中的正则表达式添加密码验证?
- back4app - 云函数在使用本地解析数据库时返回错误:“失败错误:服务器返回无效响应。”
- css - 使用 css 将引导表单组元素对齐到 50%
- sql - 完全外连接子查询工作到最后一部分然后 ORA-013113
- python - Visual Studio Code Python 扩展:默认/内置模块都不起作用(pylint、autopep8 等)