0

I have the stored procedure with the following signature:

CREATE PROCEDURE my_proc     
       @param1 varchar(4),           
       @param2 varchar(4),  
       @param3 bit, 
       @param4 decimal(14,4), 
       @param5 varchar(10)             
AS
...

In java side I have the following code:

StoredProcedureQuery proc= entityManager.createStoredProcedureQuery("my_proc");
proc.registerStoredProcedureParameter(1, String.class, ParameterMode.IN);
proc.registerStoredProcedureParameter(2, String.class, ParameterMode.IN);
proc.registerStoredProcedureParameter(3, Boolean.class, ParameterMode.IN);
proc.registerStoredProcedureParameter(4, BigDecimal.class, ParameterMode.IN);
proc.registerStoredProcedureParameter(5, String.class, ParameterMode.IN);
...
proc.setParameter(4, new BigDecimal("10000"));
....
proc.execute()

When the code executes I see the following exception in trace:

javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults
....
Caused by: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults
    at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
....
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Arithmetic overflow error converting numeric to data type numeric.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)

But this exception sometimes throws and sometimes - not. Looks like it depends on something else. But I have not ideas what it may be.

Please, help to understand the reason of issue and provide possible solutions.

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

1 Answers1

0

Actually cause of the issue was inside the stored procedure. Too huge number was inside procedure while intermediate calculations.

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710