对于PL / SQL,我是新手。我有以下PL / SQL代码块:
FUNCTION evaluate(p_sid IN NUMBER, p_min_len IN NUMBER, p_max_len IN NUMBER) RETURN VARCHAR2
IS
v_res VARCHAR2(255);
BEGIN
v_res := evaluate_batch(CURSOR(SELECT sid, stext FROM maintable WHERE sid = p_sid), p_min_len, p_max_len);
RETURN v_res;
END eval_ocr_quality;
,其中
TYPE text_rec_t IS RECORD (
rec_id NUMBER,
text CLOB);
TYPE text_rec_cur_t IS REF CURSOR RETURN text_rec_t;
FUNCTION evaluate(p_sid IN NUMBER, p_min_len IN NUMBER := 3, p_max_len IN NUMBER := 3) RETURN VARCHAR2;
FUNCTION evaluate_batch(p_cur IN text_rec_cur_t, p_min_len IN NUMBER := 3, p_max_len IN NUMBER := 3) RETURN VARCHAR2;
我在PLS-00405: subquery not allowed in this context
行
v_res := evaluate_batch
错误
我做错了什么?
答案 0 :(得分:1)
单独打开光标并将其传递到:
FUNCTION evaluate(p_sid IN NUMBER, p_min_len IN NUMBER, p_max_len IN NUMBER) RETURN VARCHAR2
IS
v_res VARCHAR2(255);
c TEXT_REC_CUR_T;
BEGIN
OPEN c FOR SELECT TEXT_REC_T(sid, stext) FROM maintable WHERE sid = p_sid;
v_res := evaluate_batch(c, p_min_len, p_max_len);
-- May need to close cursor c here if not closed in evaluate_batch
RETURN v_res;
END eval_ocr_quality;
分享并享受。