Can I pass a number for varchar2 in Oracle?

后端 未结 3 1606
独厮守ぢ
独厮守ぢ 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:11

    Oh, it is much better to convert to char rather than to numbers:

    select *
    from table
    where col1 = to_char(1234)
    

    When the col1 does not look like a number, to_number returns an error, stopping the query.

提交回复
热议问题