Issue with stored procedure INOUT parameter

Database
Enthusiast

Issue with stored procedure INOUT parameter

Hi, i am calling a stored procedure

a)
sp_getval(INOUT io_msg varchar(300));

Inside the stored procedure i am:
SET io_msg='123456789';

Now when i call sp_getval('abc'), in the sql assistant it only displays output as '123'

If i call sp_getval('abcde') it displays '12345'

In short, the output is only of the length equal to that of the input value.

How to fix this?

b) if i modify to sp_getval(OUT io_msg varchar(300)); --only as OUT parameter

and call sp_getval() it throws error '3812: The positional assignment list has too few values. '

if i call sp_getval(abc) -- note i didn't use any quotes for abc
it displays output '123456789'

Thanks,
-srinivas yelamanchili
2 REPLIES
Enthusiast

Re: Issue with stored procedure INOUT parameter

You can explicitly cast your input.

call sp_getval('abc' (VARCHAR(300)))

You are most likely hitting this problem, because SQL assistant is using the i/p variable data type to bind the o/p which is causing the truncation.
Enthusiast

Re: Issue with stored procedure INOUT parameter

Thanks Joe, that worked !
-srinivas