java.sql.SQLException: ORA-01427: single-row subquery returns more than one row

ORA-01427: 单行子查询返回多个行

sql语句如下:

select h.operator,
       to_char(h.operate_tm, ‘yyyy-mm-dd hh24:mi:ss‘) operate_tm,
       (select t.res_label name
          from [email protected] t
         where t.id = h.system_id) system_id,
       (select t.res_label name
          from [email protected] t
         where t.id = h.module_id) module_id,
       (select index_value
          from int_sys_param
         where index_type = ‘operateType‘
           and index_code = h.operate_type) operate_type,
       h.operate_page,
       h.tab_nm,
       DECODE(h.status, ‘0‘, ‘??‘, ‘1‘, ‘??‘, ‘2‘, ‘???????????‘) status,
       DECODE(h.sensitive_Id, ‘1‘, ‘????‘, ‘2‘, ‘??‘, ‘3‘, ‘??‘) sensitive_Id,
       h.ip_address,
       h.note,
       h.session_id,
       h.transaction_id,
       h.operator || ‘,‘ || nvl(h.operate_page, ‘ ‘) || ‘,‘ ||
       nvl(h.session_id, 0) || ‘,‘ || nvl(h.transaction_id, 0)
  from (select a.operator,
               a.operate_tm,
               a.system_id,
               a.module_id,
               a.operate_type,
               a.operate_page,
               a.tab_nm,
               a.status,
               a.sensitive_Id,
               a.ip_address,
               a.note,
               a.session_id,
               a.transaction_id
          from process_log a
        union all
        select b.operator,
               b.operate_tm,
               b.system_id,
               b.module_id,
               b.operate_type,
               b.operate_page,
               b.tab_nm,
               b.status,
               b.sensitive_Id,
               b.ip_address,
               b.note,
               b.session_id,
               b.transaction_id
          from iigsmdba.parameter_log b) h
 where 1 = 1
   and operate_tm >=
       to_date(‘2015-03-06 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)
   and operate_tm <=
       to_date(‘2015-03-09 23:59:59‘, ‘yyyy-mm-dd hh24:mi:ss‘)

解决办法:

首先要确认是哪个子查询引起的,以上面的sql为例

在这三条在子查询中加入rownum<2, 限制返回一行数据。可以成功查询。

select t.res_label name
          from [email protected] t
         where t.id = h.system_id and rownum<2) system_id,
       (select t.res_label name
          from [email protected] t
         where t.id = h.module_id and rownum<2) module_id,
       (select index_value
          from int_sys_param
         where index_type = ‘operateType‘
           and index_code = h.operate_type and rownum<2) operate_type,

然后依次去掉 rownum < 2,看看具体是哪一条引起的。

最后排查是下面这条语句存在多条数据:

select index_value
          from int_sys_param
         where index_type = ‘operateType‘
and index_code = h.operate_type

时间: 2024-11-06 15:17:35

java.sql.SQLException: ORA-01427: single-row subquery returns more than one row的相关文章

java.sql.SQLException:Column count doesn&amp;#39;t match value count at row 1

1.错误描写叙述 java.sql.SQLException:Column count doesn't match value count at row 1 2.错误原因     在插入数据时,插入的字段个数跟数据库表字段个数不一致 insert into student(sno,sname,sage,ssex) values(1,'张三丰','man'); 3.解决的方法     保证插入数据字段个数跟数据库表中的字段个数一致 insert into student(sno,sname,sag

jeesite导入数据库错误:java.sql.SQLException: Incorrect string value: &#39;\xE4\xB8\xAD\xE5\x9B\xBD&#39; for column &#39;name&#39; at row 1问题解决

如果使用mvn antrun:run -Pinit-db进行数据库导入导致出现如下错误: 解决方法: 这个是由于新建数据库没有选择默认字符集导致的,只要选择utf-8即可. jeesite导入数据库错误:java.sql.SQLException: Incorrect string value: '\xE4\xB8\xAD\xE5\x9B\xBD' for column 'name' at row 1问题解决

nested exception is java.sql.SQLException: Incorrect string value: &#39;\xE7\x99\xBB\xE9\x99\x86...&#39; for column &#39;image&#39; at row 1

HTTP Status 500 - Hibernate operation: could not insert: [cn.itcast.shop.product.vo.Product]; uncategorized SQLException for SQL [insert into product (pname, market_price, shop_price, image, pdesc, is_hot, pdate, csid) values (?, ?, ?, ?, ?, ?, ?, ?)

java.sql.SQLException:Column count doesn&#39;t match value count at row 1

1.错误描述 java.sql.SQLException:Column count doesn't match value count at row 1 2.错误原因     在插入数据时,插入的字段个数跟数据库表字段个数不一致 insert into student(sno,sname,sage,ssex) values(1,'张三丰','man'); 3.解决办法     保证插入数据字段个数跟数据库表中的字段个数一致 insert into student(sno,sname,sage,s

mysql 保存emoji时报,数据库报错:Caused by: java.sql.SQLException: Incorrect string value: &#39;\xF0\x9F\x98\x82\xF0\x9F...&#39; for column &#39;review&#39; at row 1

错误原因:我们可以看到错误提示中的字符0xF0 0x9F 0x98 0x84 ,这对应UTF-8编码格式中的4字节编码(UTF-8编码规范).正常的汉字一般不会超过3个字节,为什么为出现4个字节呢?实际上是它对应的是智能手机输入法中的表情.那为什么会报错呢?因为mysql中的utf-8并不是真正意义上的utf-8,它只能存储1~3个字节长度的utf-8编码,如果想存储4个字节的必须用utf8mb4类型.不而要使用utf8mb4类型,首先要保证Mysql版本要不低于 MySQL 5.5.3. 常用

Caused by: java.sql.SQLException: Incorrect integer value: &#39;&#39; for column &#39;clientId&#39; at row 41

1.错误描述 [ERROR:]2015-06-10 13:48:26,253 [异常拦截] oa.exception.ExceptionHandler org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.jav

java.sql.SQLException: Incorrect string value: &#39;\xF0\x9F\x9A\x80\xF0\x9F...&#39; for column &#39;name&#39; at row 1

1.异常提示: 12:59:10.000 [http-nio-8080-exec-40] DEBUG o.s.j.s.SQLStateSQLExceptionTranslator - Extracted SQL state class 'HY' from value 'HY000' 12:59:10.000 [http-nio-8080-exec-40] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional Sq

表情存储异常--mybatis抛出异常(java.sql.SQLException: Incorrect string value: &#39;\xF0\x9F\x92\x94&#39; for column &#39;name&#39; at row 1)

文章参考 https://blog.csdn.net/junsure2012/article/details/42171035 https://www.cnblogs.com/WangYunShuaiBaoLe/p/9055215.html https://www.jb51.net/article/112879.htm 背景 iOS端测试时发现,在备注一栏输出emoji表情,保存时出现系统异常 java项目架构 spring-boot+mybatis+德鲁伊连接池 现象 抛出  java.sql

mysql报错:java.sql.SQLException: Incorrect string value: ‘\xE4\xB8\x80\xE6\xAC\xA1...‘ for column ‘excelName‘ at row 1

一.问题 用Eclipse做项目时候报错 java.sql.SQLException: Incorrect string value: '\xE4\xB8\x80\xE6\xAC\xA1...' for column 'excelName' at row 1.而且就只有这个表的插入有问题. 二.解决 通过对比其它可以正常插入的表,发现正常的表的字符编码格式和有问题的这张表的不一样.利用Navicat工具修改字段的字符编码,问题成功解决.     原文地址:https://www.cnblogs.

MySQL报错:Cause: java.sql.SQLException: Incorrect string value: &#39;\xE6\x9D\xA8&quot;,&quot;...&#39; for column &#39;obj_value&#39; at row 1

1.插入MySQL表时,报错:Cause: java.sql.SQLException: Incorrect string value: '\xE6\x9D\xA8","...' for column 'obj_value' at row 1 错误原因:参数中带有emoji表情,插入数据库时,一些特殊字符如“繁星拜月??”,插入报异常 解决思路:因为字符编码集为utf8,不支持一些basic multilingual plane和补充字符,那么如何让mysql存储emoji表情,所以需