你可以试试这个
DECLARE TYPE rec_token IS TABLE OF VARCHAR2(100); l_rec_token rec_token; BEGIN BEGIN SELECT token BULK COLLECT INTO l_rec_token FROM mapping_view WHERE username='Peter'; EXCEPTION WHEN NO_DATA_FOUND THEN l_rec_token := rec_token(); END ; IF l_rec_token.COUNT >0 THEN FOR i IN l_rec_token.FIRST..l_rec_token.LAST LOOP <doSomeThing> END LOOP; END IF; END;