DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: exception handler

  1. #1
    Join Date
    Aug 2004
    Posts
    1

    exception handler

    hi,

    we are creating a program on which when an error occurs it should produce an alert message that will display what kind of error and its error messge.. however, were having difficulty on how to declare the exception inside the code that we have already created. since we are using the if-statement.

    we are really new about this exception handler.. so here's our code.

    DECLARE
    ALERT NUMBER;
    begin
    if :chkselect = 1 then
    forms_ddl('grant select on ' || :table_name || 'to '|| :role);
    end if;

    if :chkinsert = 1 then
    forms_ddl('grant insert on ' || :table_name || ' to ' || :role);
    end if;

    if :chkupdate = 1 then
    forms_ddl('grant update on ' || :table_name || ' to ' || :role);
    end if;

    if :chkdelete = 1 then
    forms_ddl('grant delete on ' || :table_name || ' to ' || :role);
    end if;

    end;

    ----
    this is what weve come up with, and its not functioning correctly so if you have any idea on how to insert it on the code above and what's wrong with this code.. thanks..

    IF SQLCODE = -1917 THEN
    ALERT := SHOW_ALERT('ERROR');
    END IF;
    IF SQLCODE = -942 THEN
    ALERT := SHOW_ALERT('ERROR');
    END IF;

  2. #2
    Join Date
    Jun 2004
    Location
    Ludhiana (Pb.) INDIA
    Posts
    12
    hi,
    you can use your code using pragma exception_init like the code below to track specific error no.

    DECLARE
    ALERT NUMBER;
    exp1 exception; -- define exception
    exp2 exception; -- define exception
    pragma exception_init (exp1, -1917); -- initialize with error no.
    pragma exception_init (exp2, -942 ); -- initialize with error no.
    begin
    if :chkselect = 1 then
    forms_ddl('grant select on ' || :table_name || 'to '|| :role);
    end if;

    if :chkinsert = 1 then
    forms_ddl('grant insert on ' || :table_name || ' to ' || :role);
    end if;

    if :chkupdate = 1 then
    forms_ddl('grant update on ' || :table_name || ' to ' || :role);
    end if;

    if :chkdelete = 1 then
    forms_ddl('grant delete on ' || :table_name || ' to ' || :role);
    end if;

    exception
    when exp1 then -- use them as usual exceptions
    ALERT := SHOW_ALERT('ERROR');
    when exp2 then
    ALERT := SHOW_ALERT('ERROR');
    end;

    hope this will solve your problem
    cheers
    Vikas Verma
    ___________
    It is the mark of an educated mind to be able to entertain a thought without accepting it.
    __________
    Aristotle

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width