2

Having a strange error when running a mybatis sproc that I can't quite figure out - the xml mapper I think is pretty straightforward:

<select id="executeStoredProcedure" statementType="CALLABLE">
    { 
      call update_login(aws_oracle_ext.TRUNC(#{date}) - (10 / 1440 || ' days')::INTERVAL, 
        aws_oracle_ext.TRUNC(#{date}) + (5 / 1440 || ' days')::INTERVAL, 
        1000
      ) 
    }
</select>

However, when it runs I get this error:

[ERROR] When the login_trail stored procedure is executed(****)  Time elapsed: 0.135 s  <<< ERROR!
org.springframework.jdbc.BadSqlGrammarException:

### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: update_login(timestamp without time zone, timestamp without time zone, integer) is a procedure
  Hint: To call a procedure, use CALL.
  Position: 15
### The error may exist in file [***]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: { call accounts.update_login(aws_oracle_ext.TRUNC(?) - (10 / 1440 || ' days')::INTERVAL, aws_oracle_ext.TRUNC(?) + (5 / 1440 || ' days')::INTERVAL, 1000)      }
### Cause: org.postgresql.util.PSQLException: ERROR: accounts.update_login(timestamp without time zone, timestamp without time zone, integer) is a procedure
  Hint: To call a procedure, use CALL.
  Position: 15
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: accounts.update_account_last_login(timestamp without time zone, timestamp without time zone, integer) is a procedure
  Hint: To call a procedure, use CALL.
  Position: 15
        at ***whenTheLoginTrailSPIsExecuted(LoginTrailSteps.java:83)
Caused by: org.postgresql.util.PSQLException:
ERROR: accounts.update_login(timestamp without time zone, timestamp without time zone, integer) is a procedure
  Hint: To call a procedure, use CALL.
  Position: 15
        at ****(LoginTrailSteps.java:83)

I've run the line of code manually in the db and it runs fine.

Aeonstrife
  • 553
  • 1
  • 6
  • 20
  • Try removing the braces. See this [answer](https://stackoverflow.com/a/53634135/1261766). – ave Oct 21 '21 at 18:40

1 Answers1

0

Add CDATA syntax outside the outermost braces.

buddemat
  • 4,552
  • 14
  • 29
  • 49