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 SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm


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