Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Exception Handling
I have a function which includes two blocks enclosed in a main block.
I thought any error in the first block would be handled, and then the second block would execute. However, my program gets an error in the first block (and returns the appropriate message). Then passes the error to the main block....
Here is the code. It seems to me that I'm misunderstanding what it means to "handle" an error. But I've scoured the Oracle Press _PL/SQL Programming_ book and haven't found an answer.
Any help would be appreciated.
-greg
BEGIN /* Drop Table ER_INITIAL*/
v_cursor := dbms_sql.open_cursor ;
ddlString := 'DROP TABLE GAK.er_visit_log CASCADE CONSTRAINTS' ;
dbms_sql.parse(v_cursor, ddlstring, dbms_sql.v7) ;
dbms_sql.close_cursor(v_cursor) ;
exception
when others then
dbms_output.put_line(sqlcode||' : '||sqlerrm) ; end ;
Declare
ddlString varchar2(200) ;
v_cursor number ;
BEGIN /* Drop Table ER_INITIAL*/
v_cursor := dbms_sql.open_cursor ;
ddlString := 'CREATE TABLE gak.er_visit_log ( '||chr(10)||end ;
'app_msg VARCHAR2(100), '||chr(10)||
'app_date DATE) '||chr(10)||
'TABLESPACE master_data PCTUSED 60 PCTFREE 10 ' ;
dbms_sql.parse(v_cursor, ddlstring, dbms_sql.v7) ; dbms_sql.close_cursor(v_cursor) ; exception when others then dbms_output.put_line(sqlcode||' : '||sqlerrm) ;