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 All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts count contained values of several col... DB2 5
No new posts To join 2 tables and to join 3rd tabl... DB2 8
No new posts Create a specific record/file based o... SYNCSORT 8
No new posts Extract ISPF table column headings CLIST & REXX 2
No new posts Can BPXBATCH update TAPE file COBOL Programming 3
Search our Forums:


Back to Top