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 閱讀(343) 評論(0)  編輯  收藏 所屬分類: DB
          主站蜘蛛池模板: 犍为县| 牡丹江市| 楚雄市| 远安县| 平南县| 五莲县| 平昌县| 延吉市| 台山市| 靖远县| 山阳县| 江华| 黔西县| 海口市| 昌江| 嫩江县| 古浪县| 屏山县| 张家界市| 鲁山县| 柳林县| 渭源县| 东阿县| 通化市| 大方县| 芦溪县| 韩城市| 驻马店市| 宣化县| 岑溪市| 秀山| 淮南市| 中方县| 麟游县| 东宁县| 新巴尔虎左旗| 三明市| 平和县| 嘉祥县| 项城市| 北碚区|