Can I pass a number for varchar2 in Oracle?

后端 未结 3 1636
独厮守ぢ
独厮守ぢ 2021-01-13 13:21

I have an Oracle table and a column (col1) has type varchar2(12 byte). It has one row and value of col1 is 1234

W

3条回答
  •  梦谈多话
    2021-01-13 14:15

    The problem is that you expect that Oracle will implicitly cast 1234 to a character type. To the contrary, Oracle is implicitly casting the column to a number. There is a non-numeric value in the column, so Oracle throws an error. The Oracle documentation warns against implicit casts just before it explains how they will be resolved. The rule which explains the behaviour you're seeing is:

    When comparing a character value with a numeric value, Oracle converts the character data to a numeric value.

提交回复
热议问题