PDA

View Full Version : JdbcUsersConnectionRepository together with Postgres 8.4, function ifnull not found.



kolodrevskiy
May 14th, 2011, 01:44 PM
Hi guys,
I'm using spring social version 1.0.0.M3.
Trying to use JdbcUsersConnectionRepository together with Postgres 8.4.

Here is exception I'm getting:


org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [(select ifnull(max(rank) + 1, 1) as rank from UserConnection where userId = ? and providerId = ?)]; nested exception is org.postgresql.util.PSQLException: ERROR: function ifnull(integer, integer) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.

kolodrevskiy
May 14th, 2011, 02:28 PM
as far as i know there's COALESCE function in PostgreSQL that does similar to IFNULL

kolodrevskiy
May 14th, 2011, 03:00 PM
i can add stored procedure like


CREATE OR REPLACE FUNCTION IFNULL (anyelement, anyelement) RETURNS anyelement AS
'SELECT COALESCE($1, $2) AS result'
LANGUAGE 'sql';


is there any way to avoid that?