ORA-01427: Single-line subquery returns multiple rows
The SQL statements are as follows:
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 ')
Workaround:
First, make sure which subquery is causing the above SQL to be the example
In these three rownum<2 are added to the subquery, restricting the return of one row of data. Can be queried successfully.
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,
Then remove the RowNum < 2 in turn to see which one is causing the particular article.
The final troubleshooting is that there is more than one piece of data in the following statement:
Select Index_value
From Int_sys_param
where Index_type = ' Operatetype '
and Index_code = H.operate_type
Java.sql.sqlexception:ora-01427:single-row subquery returns more than one row