This Is A FineDay

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            93 隨筆 :: 0 文章 :: 69 評論 :: 0 Trackbacks

          --簡單循環
          SET SERVEROUTPUT ON
          DECLARE
          ?????? v_t_customer t_customer%ROWTYPE;
          ?????? v_customer_id t_customer.customer_id%TYPE;
          ?????? v_customer_name t_customer.customer_name%TYPE;
          ?????? CURSOR c_t_customer IS
          ??????? --select customer_id,customer_name from t_customer where rownum <= 10;
          ??????? select * from t_customer where rownum <= 10;
          BEGIN
          ???? OPEN c_t_customer;
          ?????? LOOP
          ???????? --fetch c_t_customer into v_customer_id,v_customer_name;
          ???????? FETCH c_t_customer INTO v_t_customer;
          ????????
          ???????? dbms_output.put_line('customer_id :'||v_t_customer.customer_id||' customer_name :'||v_t_customer.customer_name);
          ???????? EXIT WHEN c_t_customer%NOTFOUND;
          ?????? END LOOP;
          ???? CLOSE c_t_customer;
          EXCEPTION
          ???????? WHEN OTHERS THEN
          ???????? ROLLBACK;?
          ???????? DBMS_OUTPUT.put_line('exception');?
          END;
          ?????
          --WHILE循環
          SET SERVEROUTPUT ON
          DECLARE
          ?????? v_t_customer t_customer%ROWTYPE;
          ?????? v_customer_id t_customer.customer_id%TYPE;
          ?????? v_customer_name t_customer.customer_name%TYPE;
          ?????? CURSOR c_t_customer IS
          ??????? --select customer_id,customer_name from t_customer where rownum <= 10;
          ??????? select * from t_customer where rownum <= 10;
          BEGIN
          ???? OPEN c_t_customer;
          ?????? --fetch c_t_customer into v_customer_id,v_customer_name;
          ?????? FETCH c_t_customer INTO v_t_customer;
          ?????? WHILE c_t_customer%FOUND LOOP
          ???????? --fetch c_t_customer into v_customer_id,v_customer_name;
          ???????? FETCH c_t_customer INTO v_t_customer;
          ???????? dbms_output.put_line('customer_id :'||v_t_customer.customer_id||' customer_name :'||v_t_customer.customer_name);
          ?????? END LOOP;
          ???? CLOSE c_t_customer;
          EXCEPTION
          ???????? WHEN OTHERS THEN
          ???????? ROLLBACK;?
          ???????? DBMS_OUTPUT.put_line('exception');?
          END;

          --游標FOR循環
          SET SERVEROUTPUT ON
          DECLARE
          ?????? v_t_customer t_customer%ROWTYPE;
          ?????? v_customer_id t_customer.customer_id%TYPE;
          ?????? v_customer_name t_customer.customer_name%TYPE;
          ?????? CURSOR c_t_customer IS
          ??????? --select customer_id,customer_name from t_customer where rownum <= 10;
          ??????? select * from t_customer where rownum <= 10;
          BEGIN
          ?????? FOR v_t_customer IN c_t_customer LOOP
          ???????? dbms_output.put_line('customer_id :'||v_t_customer.customer_id||' customer_name :'||v_t_customer.customer_name);
          ?????? END LOOP;
          EXCEPTION
          ???????? WHEN OTHERS THEN
          ???????? ROLLBACK;?
          ???????? DBMS_OUTPUT.put_line('exception');?
          END;

          posted on 2007-03-09 15:30 Peter Pan 閱讀(338) 評論(0)  編輯  收藏 所屬分類: DB
          主站蜘蛛池模板: 满洲里市| 九龙城区| 天气| 卓尼县| 海南省| 甘孜| 车险| 黄骅市| 威信县| 云南省| 营山县| 桐柏县| 通化县| 任丘市| 龙川县| 怀柔区| 襄城县| 凌源市| 赫章县| 永新县| 晴隆县| 静海县| 绥滨县| 肥城市| 中西区| 四子王旗| 淮南市| 仪陇县| 肃北| 台北县| 丽江市| 平罗县| 谢通门县| 财经| 兴仁县| 漳平市| 娄烦县| 商洛市| 阳山县| 通辽市| 泾源县|