dghtr
dghtr

Reputation: 581

Getting error invalid number in sql query

I have this SQL query:

SELECT * 
FROM coa_cook 
WHERE grt_tOOK_ID IN (301173, 301202)

and grt_tOOK_ID is of varchar2 data type in the table.

I am getting this error :

ORA-01722: invalid number

Someone has told me to put quotes between them as it is varchar2 data type please advise

Upvotes: 1

Views: 487

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201537

The column is a varchar (not a number). You could use

SELECT * FROM coa_cook WHERE grt_tOOK_ID IN ('301173','301202')

or

SELECT * FROM coa_cook WHERE TO_NUMBER(grt_tOOK_ID) IN (301173,301202)

Upvotes: 4

Related Questions