Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 stored procedure - error in dynamic sql

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Mon Jun 08, 2009 2:04 pm    Post subject: DB2 stored procedure - error in dynamic sql
Reply with quote

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;
ELSE
SET v_first_value = 'N';
SET v_query = v_query || ' WHERE A.ST_AD = ' || in_st_ad;
END IF;
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
parameter.
Is there any solution for this problem?
Back to top
View user's profile Send private message

murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Mon Jun 08, 2009 4:02 pm    Post subject:
Reply with quote

Missed quotes in dynamic sql and its working now... Thanks for those who looked into this.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Jun 08, 2009 4:11 pm    Post subject:
Reply with quote

Glad to hear that it's working now and thanks for the follow-up ... icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IDC2902I Error tzeche ABENDS & Debugging 2 Tue Mar 28, 2017 11:39 am
No new posts Need help with below DB2 error ashek15 DB2 3 Sat Mar 18, 2017 5:56 am
No new posts FINDREP Syntax Error seahawk789 DFSORT/ICETOOL 4 Thu Mar 09, 2017 10:11 pm
No new posts INVOKE WEBSERVICE error danik56 CICS 11 Thu Mar 09, 2017 11:52 am
No new posts Row not found Sql error GaganGarg DB2 7 Tue Mar 07, 2017 6:29 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us