Monday, May 30, 2016

ORA - 08103:Object No Longer Exists

This error generally occurs if the object segment not present and it is refereed in variable/cursor etc.

Ex: ON COMMIT DELETE ROWS, GTT data will be truncated and any reference to that data will fail.

--Example with GTT for ORA - 08103:Object No Longer Exists

CREATE GLOBAL TEMPORARY TABLE gtt_tab (id NUMBER) ON COMMIT DELETE ROWS;

INSERT INTO gtt_tab
     VALUES (2);

SELECT * FROM gtt_tab;

DECLARE
    cur_var   SYS_REFCURSOR;
    id_var    gtt_tab.id%TYPE;
BEGIN
    OPEN cur_var FOR SELECT id FROM gtt_tab;

    COMMIT;--Before fetch table got truncated due to commit

    LOOP
        FETCH cur_var INTO id_var;

        EXIT WHEN cur_var%NOTFOUND;
        DBMS_OUTPUT.put_line ( id_var);
    END LOOP;
END;
/

Ex: On commit data will be truncated and any reference to that data will fail.

--Example with Normal table for ORA - 08103:Object No Longer Exists

CREATE  TABLE heap_tab (id NUMBER);


INSERT INTO heap_tab
     VALUES (5);

SELECT * FROM heap_tab;

DECLARE
    cur_var   SYS_REFCURSOR;
    id_var    heap_tab.id%TYPE;
BEGIN
    OPEN cur_var FOR SELECT id FROM heap_tab;

execute immediate 'truncate table heap_tab';--Before fetch truncated tables

    LOOP
        FETCH cur_var INTO id_var;

        EXIT WHEN cur_var%NOTFOUND;
        DBMS_OUTPUT.put_line ( id_var);
    END LOOP;
END;
/

1 comment:

  1. OPEN ref_c_audit_sum_report FOR v_sql;

    v_sql1:='DROP TABLE '||v_tbl_name||' PURGE';
    EXECUTE IMMEDIATE v_sql1;
    RETURN ref_c_audit_sum_report;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    DBMS_OUTPUT.put_line ('No data found for given input values of function');
    DBMS_OUTPUT.put_line ('Exception: ' || SQLCODE || '-' || SQLERRM);

    RAISE;
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('Exception: ' || SQLCODE || '-' || SQLERRM);
    DBMS_OUTPUT.PUT_LINE ('Exception: ' || SQLCODE || '-' || SQLERRM || DBMS_UTILITY.format_error_backtrace ());
    RAISE;
    END fn_sf_audit_summary_reT_DRP;


    this is the Scenario , it is throwing error : ORA-08103: object no longer exists

    what could be the reason?

    ReplyDelete