简体   繁体   English

如何从springboot调用用户定义的sql function?

[英]How do I call a user defined sql function from springboot?

I'm trying to call a user defined function from PLSQL database, it takes several variables and return a single float.我正在尝试从 PLSQL 数据库中调用用户定义的 function,它需要几个变量并返回一个浮点数。

I've tried code like this:我试过这样的代码:

@Query(nativeQuery = true, value = "SELECT package.function("variables: 
value")
float getFuction(@Param("value") String value);

This shows an error saying "FROM keyword was not found where expected.这会显示一条错误消息“未在预期的位置找到 FROM 关键字。

I think that it should be like that (i do not have chance to check):我认为应该是这样的(我没有机会检查):

@Query(nativeQuery = true, value = "SELECT package.function(:value) FROM dual")
float getFuction(@Param("value") String value);

It is based on this answer它基于这个答案

The solution:解决方案:

@Query(nativeQuery = true, value = "SELECT package.function("variables: value") FROM dual")
float getFuction(@Param("value") String value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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