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

Can we update a primary key value of a DB2 Table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
natinuk

New User


Joined: 23 Nov 2006
Posts: 22
Location: India

PostPosted: Tue May 01, 2007 3:28 pm
Reply with quote

I am need to update one of the primary key data.
Can we update the key field ADDR as mentioned below,

Here is the query,

UPDATE NAT_TABLE
SET ADDR = 'P'
WHERE ACCOUNT = '2222222'
AND ADDR = 'S'

Thanks in Advance
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Tue May 01, 2007 4:14 pm
Reply with quote

Hi natinuk,

U can update the primary key values. But make sure that the latest updated value should not be same with the existing values, which is nothing but primary key violation.
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Wed May 02, 2007 2:07 pm
Reply with quote

Is the field ADDR part of the primary key
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Wed May 02, 2007 2:19 pm
Reply with quote

Sorry I did not pay attension to your sentence 'Can we update the key field ADDR as mentioned below,'

As far as I know changing the value of any primary key would result in a new row. Primary key is the field is the basis for selection of rows, so how can you change the value for the same. If you change it would be trated as a new row but can not replace the old one.
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 Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top