3 Replies Latest reply: Mar 5, 2013 8:35 AM by 994351 RSS

    SQL Operator Precedence Query

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

      Oracle 11g XE 11.2.0.2.0
      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!!!