ORA-06503函数返回时没有任何值

时间:2013-09-26 22:56:26

标签: oracle function

当我尝试执行此功能时,我正在获取“ORA-06503函数返回时没有值”错误。你能告诉我如何重新安排吗?

Create Function Name(in_name) Return varchar2
Is
Cursor S
IS Select v1,v2,v3 from tablename;
Begin 
    OPEN S
      Loop Fetch S into v_1, v_2, v_3;
         Exit when S%NOTFOUND;
        if (v_3 is null)
            Then For gm_rec in ( Select x,y,z,c from Tablename where
                        Tablename.x=V_1
                        and Tablename.y=V_2
                     )
            Loop
            RETURN(gm_rec.z)
            End Loop;

        if (v_3 is not null)
            Then For gm_rec1 in ( Select x,y,z,c from Tablename where
                        Tablename.x=V_1
                        and Tablename.y=V_2
                       )
            Loop
            RETURN(gm_rec1.c)
            End Loop;
                End IF;
           Close S;
       END

1 个答案:

答案 0 :(得分:1)

Create Function Name(in_name) Return varchar2
Is
Cursor S
IS Select v1,v2,v3 from tablename;
Begin 
    OPEN S
      Loop Fetch S into v_1, v_2, v_3;
         Exit when S%NOTFOUND;
        if (v_3 is null)
            Then For gm_rec in ( Select x,y,z,c from Tablename where
                        Tablename.x=V_1
                        and Tablename.y=V_2
                     )
            Loop
            RETURN(gm_rec.z)
            End Loop;

        if (v_3 is not null)
            Then For gm_rec1 in ( Select x,y,z,c from Tablename where
                        Tablename.x=V_1
                        and Tablename.y=V_2
                       )
            Loop
            RETURN(gm_rec1.c)
            End Loop;
                End IF;
           Close S;
           -- add this line
           RETURN('')
       END