stored procedures - Value can't be assigned to a host variable because it's not in range data type -


create procedure administ.student_custom_procedure1 (   in p_id integer,   in p_maths integer,    in p_science integer,    out p_obtain_marks integer,    out p_percentage decimal(3,2),    out p_status char(4) )  p1: begin          declare p_total integer;         set p_total = 200;         set p_obtain_marks = p_maths + p_science;         set p_percentage = ((p_obtain_marks * 100)/p_total);          if (p_percentage > 35)             set p_status = 'pass';         else             set p_status = 'fail';           end if;          insert administ.student_result values(p_id, p_maths, p_science, p_obtain_marks, p_percentage, p_status);  end p1 

i got error code:

sqlcode=-304, sqlstate=22003

the dec/decimal data type different assumed. data type information can found in db2 manual under create table:

"decimal(precision-integer, scale-integer) or dec(precision-integer, scale-integer) decimal number. first integer precision of number; is, total number of digits; may range 1 31. second integer scale of number; is, number of digits right of decimal point; may range 0 precision of number. if precision , scale not specified, default values of 5,0 used. words numeric , num can used synonyms decimal , dec."

so in case, hold percentages, change variable declaration:

  out p_percentage decimal(5,2),  

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -