create or replace function fun_get_itemgrade(pact_code VARCHAR2,his_code VARCHAR2) return varchar2 isitem_grade_name Varchar2(10);BEGINselect decode(a.center_item_grade,'1','甲类','2','乙类','自费')
into item_grade_name
from fin_com_compare a
where a.pact_code = pact_code
and a.his_code = his_code;RETURN item_grade_name;end fun_get_itemgrade;
提示ora-01422 返回多行的错误,但是我看了一下没有多行的啊,his_code就能定位到一行啊。select fun_get_itemgrade('02','12345678')
from --
where his_code = '12345678'即使是一行也报错
into item_grade_name
from fin_com_compare a
where a.pact_code = pact_code
and a.his_code = his_code;RETURN item_grade_name;end fun_get_itemgrade;
提示ora-01422 返回多行的错误,但是我看了一下没有多行的啊,his_code就能定位到一行啊。select fun_get_itemgrade('02','12345678')
from --
where his_code = '12345678'即使是一行也报错
解决方案 »
- 有ORACLE 9I FOR linux4 as4 x64 64BIT的版本嘛?
- 请教:为何如下的SQL执行很慢?怎么样能让他快点呢?
- Oracle数据库 sqlpuls的用法
- 求大神帮助写出这个sql(统计-按天按月按年)SQLSERVER
- 请高手帮我分析下一个ORACLE 的问题,急,在线等。。。
- system账号sqlplus能进,进oem时却提示密码错误???
- Oracle Noarchive 模式备份和恢复限制性都比 archivelog 模式大, 那 Noarchivelog 有什么优点呢?
- sum函数的应用
- sql语句的问题
- 自学Java,学习到数据库,发现oracle sql delover连接不上服务器
- oracle数据的导入
- 请问我查出了oracle锁表状态的一些表,怎样知道每张表持续锁了多长时间?
into item_grade_name
from fin_com_compare a
where a.pact_code = pact_code
and a.his_code = his_code;
能查询出多少条结果?你要控制以上的语句只返回一个值才能保证你的方法执行正确。
检查一下。
create or replace function fun_get_itemgrade(pact_code VARCHAR2,
his_code VARCHAR2)
return varchar2 is item_grade_name Varchar2(10);BEGIN
--这样打印一下结果 你就能看出来问题了
for rec in (select decode(a.center_item_grade,
'1',
'甲类',
'2',
'乙类',
'自费') de
from fin_com_compare a
where a.pact_code = pact_code
and a.his_code = his_code)
loop
dbms_output.put_line(rec.de);
end loop; /*select decode(a.center_item_grade,'1','甲类','2','乙类','自费')
into item_grade_name -- 这个地方查询到的肯定是多个值,所以into会出错
from fin_com_compare a
where a.pact_code = pact_code
and a.his_code = his_code;*/ RETURN item_grade_name;end fun_get_itemgrade;