Raket Makhim
Raket Makhim

Reputation: 157

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.

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.

Upvotes: 0

Views: 4843

Answers (3)

Taraskin
Taraskin

Reputation: 802

Nice overview about this topic can be found here: https://www.baeldung.com/spring-data-jpa-stored-procedures

Upvotes: 0

Raket Makhim
Raket Makhim

Reputation: 157

The solution:

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

Upvotes: 0

lczapski
lczapski

Reputation: 4140

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

Upvotes: 3

Related Questions