3 Replies Latest reply on Mar 5, 2013 2:35 PM by 994351

    SQL Operator Precedence Query

      I don't understand why the first query works and the second doesn't.

      Oracle 11g XE
      HR Schema

      select salary*10/100+100 || ' 10% Salary plus 100' from employees;

      select '10% Salary plus 100 ' || salary*10/100+100 from employees;

      Error Message: ORA-01722: invalid number

      I did look at the cause of the error code. (The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal. Only numeric fields or character fields containing numeric data may be used in arithmetic functions or expressions. Only numeric fields may be added to or subtracted from dates.)

      If that's the case, shouldn't both the queries fail?

      Would appreciate if someone can answer this.. Thanks!!!