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
 

 

Can we update a primary key value of a DB2 Table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Can we update a primary key value of a DB2 Table
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    Post subject: Hi
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    Post subject:
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    Post subject:
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    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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


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