我有功能,如:循環數組提供了錯誤的Oracle
create or replace function dedup_temp
return varchar2
as
TYPE OriType IS TABLE OF deduporiginal%ROWTYPE;
type1 OriType;
num number;
begin
select count(1) into num from deduporiginal;
select * into type1(num) from deduporiginal where rownum < 125;
for i in 1 .. type1.count
loop
DBMS_OUTPUT.put_line('v_month_va(i): '||type1(i).name);
end loop;
return 'DONE';
end dedup_temp;
它編譯成功,但給錯誤,而與查詢一樣運行它
select dedup_temp() from dual;
錯誤:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "CRESTELDEDUPDEV.DEDUP_TEMP", line 9
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requested
如果我想返回type1,應該返回什麼類型的函數? – chetan 2011-12-20 07:12:56