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

Thread: Validating Math Equations

  1. #1
    Join Date
    Oct 2000
    Location
    Halifax, Nova Scotia
    Posts
    197
    Hello all

    I need to write a procedure that accepts a math equation and verifies that the equation is valid.

    i.e 2x+5*5x

    This equation is in fact valid in Oracle but it does not do the math properly. If x is equal to 1 then the equation gets processed as follows

    21+5*51 instead of 2*1+5*5*1

    Has anyone ever dealt with a situation like this. I need to be able to scan the equation and check for a number infront of the x. All other situations the equation is invalid anyway.

    Thanks in advance for any help you can provide
    Don't be afraid to try something new. Amateurs built the Ark, professionals built the Titanic

  2. #2
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    create or replace
    function eval_expr(p_expr varchar2) return boolean is
    begin
    execute immediate 'select '||p_expr||' from dual';
    return true;
    exception when others then return false;
    end;
    /


  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    dupe bummer

  4. #4
    Join Date
    Oct 2000
    Location
    Halifax, Nova Scotia
    Posts
    197
    Thanks

    That's alot simpler than the code I was working with

    Don't be afraid to try something new. Amateurs built the Ark, professionals built the Titanic

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