ORA-01427single-row subquery returns more than one

简介: 今天改bug遇到了一个错误,如题.是别人改了我的sql,没经过严格的测试,后来发现改坏了.出错的语句如下 : select g.id, g.
今天改bug遇到了一个错误,如题.是别人改了我的sql,没经过严格的测试,后来发现改坏了.出错的语句如下 :
select
	    g.id, g.account_id, g.account_relationship_id
            , (select le.DISPLAY_NAME
               from g, lov_element le
               where g.GRIEVANCE_TYPE = le.VALUE
               and le.LOV_NAME = 'GRIEVANCE_TYPE') grievance_type
            , g.requestor_name, g.continue_coverage_flag
            , g.comments, g.creation_date, g.approved_flag, 
            p.first_name,p.id
		from
             account_relationship ar,g, person p ,account a

产生这个错误是由于子查询中的结果如果 返回结果有两个以上,就会导致oracle抛出这个错,因为查询条件不能支持多个查询参数.可以做如下修改:
select
	g.id, g.account_id, g.account_relationship_id
            , nvl(lov_list1.DISPLAY_NAME, ' ') as grievance_type
            , g.requestor_name, g.continue_coverage_flag
            , g.comments, g.creation_date, g.approved_flag, p.first_name, p.middle_initial, p.last_name, p.party_id
		from
			account_relationship ar,g, person p ,account a,
      (SELECT l.lov_name,l.display_name,l.value,enabled from lov_list l where (lov_name='GRIEVANCE_TYPE' and enabled='T')) lov_list1

要点是通过在where条件中加入需要查询的结果子集来将数据库中保存的value替换成页面上显示的display name
目录
相关文章
|
12月前
|
数据库
解决which is not functionally dependent on columns in GROUP BY clause;...sql_mode=only_full_group_by
解决which is not functionally dependent on columns in GROUP BY clause;...sql_mode=only_full_group_by
254 0
|
关系型数据库 MySQL 数据库
View ‘information_schema.SCHEMATA‘ references invalid table(s) or column(s) or function(s) or define
View ‘information_schema.SCHEMATA‘ references invalid table(s) or column(s) or function(s) or define
222 0
1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause
1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause
202 0
1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause
|
SQL 关系型数据库 MySQL
MySQL:The used SELECT statements have a different number of columns
执行SQL报错:The used SELECT statements have a different number of columns
737 0
MySQL:The used SELECT statements have a different number of columns
|
PHP
【PHP报错集锦】Integrity constraint violation: 1052 Column 'vt_id' in where clause is ambiguous
【PHP报错集锦】Integrity constraint violation: 1052 Column 'vt_id' in where clause is ambiguous
331 0
【PHP报错集锦】Integrity constraint violation: 1052 Column 'vt_id' in where clause is ambiguous
|
关系型数据库 MySQL 数据库
MySQL - Column 'id' in where clause is ambiguous
MySQL - Column 'id' in where clause is ambiguous
908 0
|
SQL 关系型数据库 MySQL
MySQL - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
MySQL - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
228 0
How to give query view parameter values in APF
How to give query view parameter values in APF
119 0
How to give query view parameter values in APF
|
SQL Java 数据库连接
JPA异常:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
JPA异常:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
2006 0