Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MDB2 fetchRow fails silently when an exception occurs when getting a row

doug8294Aug 9 2015 — edited Aug 21 2015

How can I determine that a PL/SQL exception occurred when calling MDB2 fetchRow?

For example, I'll create a table called test_table with ids from 1 through 10000, as well as a PL/SQL function called make_error that just raises an error occasionally.  Perhaps on the thousandth row fetched, for example. 

    create table test_table (id NUMBER);

    /

    DECLARE

        j    NUMBER (10);

    BEGIN

        FOR j IN 1 .. 10000

        LOOP

            INSERT INTO   test_table

                  VALUES   (j);

        END LOOP;

    END;

    /

   

    create or replace

    function make_error(i_num IN NUMBER) RETURN NUMBER AS

      test_exception EXCEPTION;

    BEGIN

      IF (i_num MOD 1000) = 999 THEN

         RAISE test_exception;

      END IF;

      RETURN i_num;

    END;

    /

I do all of the MDB2 setup then fetch rows with something like this:

    $sql = "select make_error(id) from test_table";

    $results= $db->query($sql);

   

    while ($row = ($results->fetchRow(MDB2_FETCHMODE_ASSOC)))

    {

      $count++;

      print_r($row);

    }

   

    echo " COUNT IS $count ";

It doesn't fetch all 10000 rows.  It just fails silently around fetching row 500. If I didn't know, I would think that this is all of the rows in the result set.

Comments

Christopher Jones-Oracle

I did a quick experiment with try/catch; the catch wasn't executed.

Did you debug through MDB2/Driver/oci8.php to see if fetchRow() is propagating the error?

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 18 2015
Added on Aug 9 2015
1 comment
859 views