catching exceptions [message #40869] |
Fri, 08 November 2002 11:40 |
thundercat
Messages: 10 Registered: August 2002
|
Junior Member |
|
|
Hello all,
I had a post earlier where I was asking if there was a catch all exception handler. Thanks for the responses, I have come up with another problem. The following code produces an error
All I want to do is move data from one table to another, and if something happens like constraint violation, I want to move that data to an error table. The following code is just a tester, and not the actual.
DECLARE v_first_name VARCHAR2(20);
v_last_name VARCHAR2(20);
CURSOR MOVING_DATA IS
SELECT FIRST_NAME, LAST_NAME
FROM ODBC_TABLE1;
BEGIN
OPEN MOVING_DATA;
LOOP
FETCH MOVING_DATA INTO v_first_name, v_last_name;
EXIT WHEN MOVING_DATA%NOTFOUND;
INSERT into ODBC_TABLE2 (FIRST_NAME, LAST_NAME) values (v_first_name, v_last_name);
EXCEPTION
WHEN OTHERS THEN
INSERT INTO ODBC_ERROR_TEST(FIRST_NAME, LAST_NAME)
VALUES(v_first_name, v_last_name);
END;
END LOOP;
CLOSE MOVING_DATA;
END;
|
|
|
|