IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 Stored Procedure - SUBSTR


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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

Moderator Emeritus


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

PostPosted: Mon Jan 10, 2011 10:46 am
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: 1281
Location: Belgium

PostPosted: Wed Jan 12, 2011 4:38 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Invoke stored procedure via batch JCL. DB2 2
No new posts Calling COBOL DB2 program from a COBO... COBOL Programming 2
No new posts Cond parameter and Rc code of a proce... JCL & VSAM 5
This topic is locked: you cannot edit posts or make replies. Internal Autonomous Stored Procedure ... DB2 6
No new posts Stored procedure cpu utilization DB2 1
Search our Forums:

Back to Top