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
 

 

Cobol Accept date VS Db2 Current time stamp

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

New User


Joined: 22 Aug 2008
Posts: 20
Location: india

PostPosted: Fri Oct 05, 2012 7:59 pm    Post subject: Cobol Accept date VS Db2 Current time stamp
Reply with quote

Hi,

I am writing a cobol-DB2 stored procedure. I need current date and time in the program.

Which one is the best for CPU utilisation
1) ACCEPT WS-CURRENT-DATE FROM DATE
ACCEPT WS-CURRENT-TIME FROM TIME

or

2) EXEC SQL SET :CURR-TIME = CURRENT_TIMESTAMP END-EXEC

Thanks,
Vinodh P M
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Oct 05, 2012 9:17 pm    Post subject:
Reply with quote

Why do you care about CPU utilization? Unless you are executing your code BILLIONS or TRILLIONS of times, the difference in execution time will be so small you couldn't tell the difference. Current COBOL compiled code executes tens or even hundreds of millions of COBOL statements per second of CPU time on z machines, so worrying about CPU utilization is completely archaic and obsolete -- unless the program is discovered to have a problem. Such a problem, however, would NOT be with using ACCEPT versus the database to get date / time.

Invoking the database to get date / time would tend to use more overall CPU since the ACCEPT statements are 30 pseudo-assembler instructions using the COBOL V3R4 compiler. However, if you have coded your program to use one or the other, don't change it since you would use more CPU time to recompile the code than you are likely to save in years of execution.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Oct 05, 2012 9:32 pm    Post subject:
Reply with quote

With accept there is a very slight chance that the date could change between the two calls so you would end up with time that doesn't go with the date.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Sat Oct 06, 2012 4:56 am    Post subject:
Reply with quote

Quote:
With accept there is a very slight chance that the date could change between the two ...


Yes, but it'll never happen until the first month-end/year-end run in Production....
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Sat Oct 06, 2012 9:29 pm    Post subject: Reply to: Cobol Accept date VS Db2 Current time stamp
Reply with quote

time-stamping is a peeve of many auditors usually ending in a <religion> war

according to many of them all the <events> of a process should have the <same> timestamp in order to be able to relate them

the picky ones sometimes insist on two timestamps one related to the <process> and one related to the <event>
the double time-stamp might make sense significant when there are <concurrent> updates
from different <sources> and one process spans a looong time interval

where a process is a unit of work, an online transaction or a batch program
Back to top
View user's profile Send private message
NahuelTori

New User


Joined: 29 Sep 2008
Posts: 9
Location: Argentina

PostPosted: Wed Dec 04, 2013 12:42 am    Post subject:
Reply with quote

With the SQL command, you have to had the spacial care to control the SQLCODE of the execution. It is common to have this as the first SQL command executed in the program, leading to possible unreacheable Abends due to -805 bind errors.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Wed Dec 04, 2013 1:16 am    Post subject:
Reply with quote

The precision needed of date and time might be the deciding factor as to which ones you choose.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Wed Dec 04, 2013 2:51 pm    Post subject:
Reply with quote

I agree with Robert that unless you are executing your code BILLIONS or TRILLIONS of times, the difference in execution time will be so small you couldn't tell the difference.

However, with the information in hand read is as the only DB2 statement in the program is for TIMESTAMP, choose:
Code:
ACCEPT WS-CURRENT-DATE FROM DATE
ACCEPT WS-CURRENT-TIME FROM TIME


This next statement of mine might call in for a long argument, though, if time component is not that critical part for your LUW, COBOL ACCEPT is a preferred way to go compared to DB2 timesstamp - why? Nahuel has explained that already. But if your program runs once a day, the "savings" might be too small to be called as savings.
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
This topic is locked: you cannot edit posts or make replies. Get a job submitted itself every time... arunsoods JCL & VSAM 3 Tue Nov 22, 2016 4:05 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm


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