Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
I'm facing a strange problem is db2 stored procedure. A dynamic query is written in the SP and it throws sqlcode -206 at runtime. The query has 6 conditions in where clause and the error throws in one of the condition. When the value is hard coded instead of getting from i/p parameter then the SP executes correctly.
Example: IF v_first_value = 'N' THEN
SET v_query = v_query || ' AND A.ST_AD = ' || in_st_ad;
SET v_first_value = 'N';
SET v_query = v_query || ' WHERE A.ST_AD = ' || in_st_ad;
The query fails in this condition at run time. If i change
A.ST_AD = ' || in_st_ad to A.ST_AD = ''CA''' then it executes correctly.
Also when the query is changed to static, then the SP executes successfully even if the value for the column is got from i/p
Is there any solution for this problem?