Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPQL: convert varchar to number

How can i convert varchar to number in JPQL ???

I managed to do that in sql (Oracle) with this query:

SELECT Decode(Upper(column_name), Lower(column_name), To_Number(column_name), -1)
FROM table

I want to do this conversion with JPQL.

Thanks for your help

like image 499
user3032749 Avatar asked Nov 25 '13 14:11

user3032749


Video Answer


1 Answers

You can do the next:

CAST(e.salary AS NUMERIC(10,2))

Additionally, you can try:

  • FUNC('TO_NUMBER', e.areaCode), FUNC allows for a database function to be call from JPQL.

  • SQL('CAST(? AS CHAR(3))', e.areaCode), SQL allows for the usage and integration of SQL within JPQL.

like image 101
Paul Vargas Avatar answered Oct 25 '22 06:10

Paul Vargas