简体   繁体   中英

NOW() of SQL in Slick FRM

I am using Slick FRM to have it generate SQL code and connect to a MySQL server.

I failed to find a way to call NOW() function in SQL provided by MySQL server from within Scala code but have to generate a Datetime object and call its now() method in Scala code which results in obtaining the current time of the server that runs Scala application rather than the server time of the MySQL which would be obtained by calling NOW() in SQL code.

Can anyone shed some light ? Thanks.

You are looking for User-Defined Features

In your case something like this should work:

val now = SimpleLiteral[java.sql.Date]("NOW")

EDIT

According to GitHub issue it is not possible to use user defined functions in other use cases than queries. So it seems it is not a fit for your problem.

In that case I guess you have to use plain SQL for that one.

sqlu"""update TAoneBattSysRealtime set updateTime = NOW() where hwid = ${r.hwid}""" 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM