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
答案 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