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 - SUBSTR

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

New User


Joined: 07 Jun 2007
Posts: 23
Location: USA

PostPosted: Mon Jan 10, 2011 6:05 am    Post subject: DB2 Stored Procedure - SUBSTR
Reply with quote

Hi All,

We had written one DB2 stored procedure and worked fine. This will be called remotely by Java application. then we changed two cursors where condition for Timestamp. we used
substr(char(timestamp),1,16) = substr(char(:variable),1,16). This is working fine through QMF and we tested the stored procedure as batch program, it worked there also. but when this was called by Java application, then it's not working. It's saying successful but not updating or inserting anything in the database. Please if anyone have or encountered this kind of issue in Stored procedure, Please help me.

Thank you & regards,
Harish.
Back to top
View user's profile Send private message

singhju

New User


Joined: 01 Dec 2010
Posts: 25
Location: Gurgaon

PostPosted: Mon Jan 10, 2011 10:41 am    Post subject:
Reply with quote

Harish,

you are saying that you cahnged two cursors and then you are saying it is not updating or inserting into database. Little bit confused.

Can you please give some more details like what exact operation are you trying to do and what is the value in :varibale?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jan 10, 2011 10:46 am    Post subject:
Reply with quote

Hello,

Have you considered that the insert/update has happened and was then backed out. . .

Suggest you add some diagnostic test code to show if the insert/update SQL is being executed.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Wed Jan 12, 2011 4:38 pm    Post subject:
Reply with quote

I'm absolutely not sure about this, as i can't find the details of an error I had a while back. But I'll mention it, maybe it points you in the right direction.

in Java or (any other dynamic SQL ?) you can not use parameter markers within functions
i.e. "substr(char(?),1,16) " won't prepare



substr(char(timestamp),1,16) = substr(char(:variable),1,16).


besides performance wise it would be better to make 2 variables :
1 containing fe. : '2011-01-12-12.06.00.000000'
and 1 cont. : '2011-01-12-12-06.59.999999'
and rewrite your query as "timestamp between :variable1 and variable2"
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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Is possible to call subprogram from c... cmsmoon COBOL Programming 3 Fri Aug 05, 2016 6:46 pm
This topic is locked: you cannot edit posts or make replies. Stored procedure on Federated thru DB2 arif677 DB2 6 Tue May 31, 2016 11:48 pm


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