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
 

 

Timestamp as a part of primary key

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

New User


Joined: 01 Jun 2006
Posts: 23
Location: Sinagpore

PostPosted: Thu Jun 15, 2006 11:23 am    Post subject: Timestamp as a part of primary key
Reply with quote

hi

Is Timestamp being a part of primary key is good or not????

Every time i insert a record into the table coz of the timestamp,
there is no chance of voilation of primayy key.But ,wht is the other side of having timestamp as a part of primary key.


Cheers

venkat
Back to top
View user's profile Send private message

anamikak

New User


Joined: 10 May 2006
Posts: 64
Location: Singapore

PostPosted: Thu Jun 15, 2006 1:13 pm    Post subject:
Reply with quote

You could go in for timestamp as primary key when implementation of multiple column primary key is difficult or you do not have any other column as your choice for primary key.

To use timestamps for primary key values you create a column and assign it the TIMESTAMP data type with NOT NULL WITH DEFAULT. When inserting rows DB2 will automatically assign the column a value equal to the current timestamp at the time the row is inserted(in other words dont give a value for this column) . This works well excepting when you are inserting new values so rapidly that the two rows are inserted at the same exact time. Hence you provide retry logic in your application program in case duplicate key values are inserted. Check for SQLCODE ?803, and if received, retry the INSERT. It is possible to get duplicate key values when two transactions try to insert to the table at exactly the same time.
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 Converting EBCDIC to Unicode (TimeStamp) muralikrishnan_new COBOL Programming 2 Mon Jul 25, 2016 10:42 pm
No new posts SFTP to primary and secondary servers mallik4u JCL & VSAM 4 Tue Jun 07, 2016 12:52 pm
No new posts Convert Timestamp Value mrdinesh DFSORT/ICETOOL 7 Thu May 05, 2016 6:01 pm
No new posts Comparing timestamp in Synscort l.nethaji SYNCSORT 13 Wed Jan 20, 2016 4:47 pm
No new posts pass numeric value of length 14 to ti... Ralph Zbrog Java & MQSeries 4 Fri Jan 15, 2016 3:20 pm


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