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.