4 Replies Latest reply on Jun 5, 2019 1:00 PM by Mike Kutz

    Arbori:  negation bug?

    Mike Kutz

      I'm trying to ensure that WHEN OTHERS exception handlers contain a RAISE or RAISE_APPLICATION_ERROR;

       

      I can identify the nodes with the required RAISE/RAISE_APPLICATION_ERROR.  But, when I try to negate those, I get an error (in the Arbori Editor).

       

      Is this a bug?  or did I write something wrong?

       

      Thanks

       

      MK

       

      Arbori Code

      WhenOthesrWithoutRaise:
      -- identifies the WHEN OTHERS exception block
        [ot) excptn_choice
      & ?ot = 'others'
      & ot^ = node
      & [node) excptn_handler
      &  
        ! (  -- pick all nodes except where these PASS (negation is broken)
            ([raise) raise_stmt & node <= raise & ot^ <= raise ) -- RAISE  (didn't test "RAISE no_data_found;" type syntax)
          | ([raise) name_wo_function_call & ?raise = 'RAISE_APPLICATION_ERROR' & node <= raise^ & ot^ <= raise ) -- RAISE_APPLICATION_ERROR
        )
      ;
      

       

      Test PL/SQL:

      begin
      begin
          null;
      exception
          when others then
              null;
      end;
      
      
      begin
          null;
      exception
          when others then
              raise;
      end;
      
      
      begin
          null;
      exception
          when others then
              RAISE_APPLICATION_ERROR( err_num, err_str );
      end;
      begin
          null;
      exception
          when others then
            -- comments
            do_something();
            -- place RAISE at a different tree level
            if true then raise; end if;
      end;
      
      
      end;
      /
      
        • 1. Re: Arbori:  negation bug?
          Vadim Tropashko-Oracle

          You are correct, the negation operator works properly only when applied to atomic predicates. Consequently, to avoid wrong query results when negating complex expression, Arbori flags syntax error.

           

          What you are looking in your example is the minus operator:

           

          AllOtherClauses: ...

           

          ProperlyFormedOtherClauses: ...

           

          WhenOthesrWithoutRaise: AllOtherClauses - ProperlyFormedOtherClauses;

          • 2. Re: Arbori:  negation bug?
            Mike Kutz

            I'm assuming you and ThatJeffSmith realize:

                 Since we can "identify a specific code pattern" within our worksheet and then highlight it,

                 We now want to "identify a specific code pattern" within our Database and then (manually) fix it.

             

            Or ... at least... that's what I desire.

             

             

             

            MK

            • 3. Re: Arbori:  negation bug?
              Vadim Tropashko-Oracle

              I don't understand your comment. To clarify here is your solution almost verbatim in 19.1 (in 19.2 it is slightly different):custom syntax.png

              • 4. Re: Arbori:  negation bug?
                Mike Kutz

                Vadim Tropashko-Oracle wrote:

                 

                I don't understand your comment.

                 

                I would like to have the ability to generate a report that shows how many occurrence of each rule is found within each DB Object that are owned by the Schemas I have selected.

                 

                eg

                 

                This will give me some information that I can use to decide where I should concentrate "code improvement" efforts/resources.

                 

                I'm assuming this would be a "Feature Request"

                 

                MK