Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

oracle和db2語法

請問一下

這是oracle的一段cursor語法 判斷這個cursor若沒關起來就關閉它

(1)

IF AAA%ISOPEN THEN

CLOSE AAA;

END IF;

(2)若是這個cursor沒有找到資料就關閉她

IF AAA%NOTFOUND THEN

CLOSE AAA;

END IF;

(3) 指標

<< P1 >>

GOTO P1;

請問一下(1) (2) (3) 的狀況,在db2語法要怎麼寫呢?

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    這是 DB2 的系統 not supported:

    ISOPEN

    ROWCOUNT

    SQL%ISOPEN

    SQL%BULKROWCOUNT

    這是 DB2 的系統

    DECLARE CONTINUE HANDLER for NOT_FOUND

    SET AT_END = 1;

    OPEN UPDATE_CURSOR;

    FETCH_LOOP:

    LOOP

     FETCH UPDATE_CURSOR INTO decArchiveRetrievalID;

      SET intImageCount = (SELECT COUNT(*) FROM ......);

      IF AT_END = 1 THEN

        LEAVE FETCH_LOOP;

      ELSEIF intImageCount = (SELECT ICOUNT FROM ......) THEN

        ITERATE FETCH_LOOP;

      END IF;

    END LOOP FETCH_LOOP;

    CLOSE UPDATE_CURSOR;

    END P1

    這是 Oracle的系統<<供你參考>>Oracle 9i/10g/11g

    DBMS_OUTPUT.PUT_LINE('Invoice Rule: Immediate');

    v_ResultStr := 'Fetching_OrderLine';

    OPEN Cur_OrderLine (o.C_Order_ID);

    FETCH Cur_OrderLine INTO ptr_ol;

     IF (Cur_OrderLine%NOTFOUND) THEN

      DBMS_OUTPUT.PUT_LINE('- No Lines -');

      GOTO Next_Order;

     END IF;

    ---------------指標

    <<Next_Order>>

     v_ResultStr := 'ClosingLine';

     IF (Cur_OrderLine%ISOPEN) THEN

      CLOSE Cur_OrderLine;

     END IF;

     IF (Cur_InOutLine%ISOPEN) THEN

      CLOSE Cur_InOutLine;

     END IF;

    ---------------

    Source(s): SAP / Oracle 顧問 OpenSource ERP Adempiere 北美與中國(含台灣區)技術支持團隊
Still have questions? Get your answers by asking now.