oracle DBMS_OUTPUT.PUT_LINE()

wang_0720發表於2013-12-03
oralce在執行儲存過程時如果要顯示DBMS_OUTPUT.PUT_LINE()的輸出資訊,要在開啟serveroutput。在sqlplus中set serveroutput on即可。DBMS_OUTPUT.PUT_LINE()輸出資訊分割符為||。
CREATE OR REPLACE PROCEDURE stu_proc IS
        v_Id student.id%TYPE := 1;
        v_Counter number;
BEGIN
        select count(*) into v_Counter from student;
        IF v_Counter>0 THEN
                DBMS_OUTPUT.PUT_LINE('rows is:'||v_Counter);
                delete from student;
                DBMS_OUTPUT.PUT_LINE('all data in student table is deleted');
        END IF;
        LOOP
                insert into student (id,name,score)
                values (v_Id,'wang','80');
                v_Id := v_Id + 1;
                IF v_Id > 20 THEN
                        EXIT;
                END IF;
        END LOOP;
END;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27181165/viewspace-1062050/,如需轉載,請註明出處,否則將追究法律責任。

相關文章