All Forums Database
bp0308 4 posts Joined 03/14
30 May 2014
Stored Procedure returning unexpected results
replace PROCEDURE db.sp_test (IN year_num INTEGER,IN descr varchar(250))
DYNAMIC RESULT SETS 1
BEGIN
DECLARE results1 CURSOR WITH RETURN ONLY FOR
select b.column, cast((a.column *100) as decimal(5,2)) as pct, a.column
from db1.tab1 as a inner join
db1.tab2 as b on(a.some_column=b.some_column) inner join
db2.tab3 as c on(a.column=c.column) and (a.column=c.column)
where a.column=year_num and c.column=descr
order by 
a.column1,a.column2,a.column3;
OPEN results1;
END;

When I call the procedure above - CALL db.sp_test (2014,'some string with spaces') - I get a result set similar to what I get if I ran the inside SQL with only the first clause in the where condition. In other words, the 2nd parameter is not getting passed correctly on to the 2nd clause in the where condition.
The inside SQL does give the expected result, if ran separately.
Not sure what is the problem here. I am stuck with this :)
Any help will be great.
-Thanks for your time.

You must sign in to leave a comment.