Skip to Main Content

SQL & PL/SQL

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!

Raised exception

ORA-00666Jan 6 2016 — edited Jan 6 2016

Hi, I need to have 2 procedures in a package. One procedure with select into statement which causes error and raises it, and second procedure to handle all the errors and place them into errors table.

What I have done:

create or replace package paketas as

  procedure error_log;

  procedure ins;

end;

/

create or replace package body paketas as

   procedure ins as

    l_num pls_integer;

  begin

    select 0

    into   l_num

    from   dual

    where  1 = 0;

    raise;

  end ins;

      procedure error_log as

          n_code number;

      n_massage varchar2(100);

    begin

    exception -----------<<<<<<<<<<<<This place causes error

    when others then

    n_code := SQLCODE;

    n_massage := SUBSTR(SQLERRM, 1, 100);

    INSERT INTO errors (e_id, code, message, e_time)

    VALUES (er_id.nextval, n_code, n_massage, sysdate);

  end error_log;

end paketas; 

/

And in package body I get error:

"PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:

   ( begin case declare exit for goto if loop mod null pragma

   raise return select update while with <an identifier>

   <a double-quoted delimited-identifier> <a bind variable> <<

   continue close current delete fetch lock insert open rollback

   savepoint set sql execute commit forall merge pipe purge

"

Could you help me to solve this situation?

This post has been answered by KayK on Jan 6 2016
Jump to Answer

Comments

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

Post Details

Locked on Feb 3 2016
Added on Jan 6 2016
7 comments
1,437 views