Amal
Amal

Reputation: 89

DB2 - The data type of the source value is not compatible with the data type of the target column, variable,

I have the following stored procedure created in db2. However it gives an error stating that "[SQL0408] Value for column, variable, or parameter NUMERIC1 not compatible. Cause . . . . . : The data type of the source value is not compatible with the data type of the target column, variable, or parameter NUMERIC1" in the return statement.

 CREATE or replace PROCEDURE mbs.mbstest2912()
        
          LANGUAGE SQL
          BEGIN atomic
       
       DECLARE numeric1  numeric(3,2);  
       
        set numeric1 =1.22;
        return numeric1 ;
        end

I dont see any root cause for this.How is it possible to rectify this error?

Upvotes: 0

Views: 482

Answers (1)

Mark Barinstein
Mark Barinstein

Reputation: 12314

Refer to the RETURN statement documentation link.

expression
Specifies a value that is returned from the routine:

If the routine is a scalar function, ...
If the routine is a table function, ..
If the routine is a procedure, the data type of expression must be INTEGER. If the expression evaluates to the null value, a value of zero is returned.

Use output parameter if you want to return result of some custom data type.

Upvotes: 1

Related Questions