DECLARE
V_NUM NUMBER := 0;
SQL_STRING VARCHAR2(100);
V_NAME INFO_STU_1.NAME%TYPE;
BEGIN
SQL_STRING := 'select t.name from info_stu_1 t where t.id = :1';
WHILE V_NUM <> -1 LOOP
V_NUM := &C_NUM;
EXECUTE IMMEDIATE SQL_STRING
INTO V_NAME
USING V_NUM;
DBMS_OUTPUT.PUT_LINE(V_NAME);
END LOOP;
END;
DECLARE
V_NUM NUMBER := 0;
SQL_STRING VARCHAR2(100);
V_NAME INFO_STU_1.NAME%TYPE;
BEGIN
SQL_STRING := 'select t.name from info_stu_1 t where t.id = :1';
WHILE V_NUM <> -1 LOOP
V_NUM := &C_NUM;--只会执行一次
EXECUTE IMMEDIATE SQL_STRING
INTO V_NAME
USING V_NUM;
DBMS_OUTPUT.PUT_LINE(V_NAME);
END LOOP;
END;