This Is A FineDay

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            93 隨筆 :: 0 文章 :: 69 評(píng)論 :: 0 Trackbacks

          --簡(jiǎn)單循環(huán)
          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循環(huán)
          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;

          --游標(biāo)FOR循環(huán)
          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) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): DB
          主站蜘蛛池模板: 墨竹工卡县| 宜昌市| 广西| 青州市| 调兵山市| 湄潭县| 巴林右旗| 江陵县| 宝丰县| 黄浦区| 宣城市| 永安市| 利川市| 儋州市| 静海县| 耒阳市| 安庆市| 苍溪县| 湘潭市| 建昌县| 八宿县| 阳原县| 和平区| 竹溪县| 马公市| 榕江县| 天台县| 和政县| 兖州市| 双江| 蓬莱市| 乐山市| 拜泉县| 正定县| 苏州市| 彭泽县| 五台县| 龙游县| 定远县| 莱西市| 汶川县|