-1

当我尝试执行此函数时,我收到“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
4

1 回答 1

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
于 2013-09-26T23:05:59.087 回答