Search code examples
db2ibm-midrange

DB2 quotes around numeric values


I have been wondering why DB2 SQL statements work even if there are quotes around numeric values.

For example, SELECT * FROM EMPLOYEE WHERE EMPNO = '3' where EMPNO is a number works as fine as SELECT * FROM EMPLOYEE WHERE EMPNO = 3? Why is this so? Aren't quotes for characters only?


Solution

  • Because the DB will implicitly cast values if it needs to.

    From the v5r3 SQL Reference
    What’s new for V5R3

    • Implicit conversion between strings and numeric data types