'cast'에 해당되는 글 1건

  1. 2020.11.17 ERROR: operator does not exist: bigint = character varying
PostgreSQL2020. 11. 17. 13:16

 

 

 

해당 에러가 나는 경우는, mybatis에서 where 조건 대입시 문제가 생기거나..
캐스팅을 잘못해서 생기는 오류라고 한다.

error)
org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

에러가 난 위치(mybatis xml 파일 안에서의 문제였음)>

 

SELECT filekey
		 ...
	  FROM tb_file
	 WHERE filekey = #{filekey}
	   AND del_yn = 'N'

 

 

integer를 의도하고 대입한건데, character varying으로 인지해서 생기는 문제였다.

해결 코드>

 

SELECT filekey
		 , filename
		 , filepath
		 , comment
	  FROM tb_file
	 WHERE filekey = CAST(#{filekey} AS INTEGER)
	   AND del_yn = 'N'

 

 

CAST를 써주자!!!

 

 

Posted by 사슴영혼'-'