Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Change Primary Key field contents

Former Member
0 Kudos

Hi,

Is it possible to change the contents of Primary Key field values in a table using UPDATE statement? (Primary Key can be One field or can be Group of fields)

If not possible, any other alternative solution.

Thanks in advance.

Rgds

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

It is written that "You cannot change the primary key when you UPDATE a table for which a <b>synchronous matchc</b>ode is defined". I suppose that an altenative way is to delete the old values and to insert the new ones.

Svetlin

6 REPLIES 6

Former Member
0 Kudos

Hey,

Inorder to identify a unique row we define Primary key. This promary can be a single key (or) it can be collection of fields.

Important:

It's not possible to change a primary key while updating a table.

Cheers,

Venkat Ramanan

0 Kudos

Hello,

You cannot change the primary key when you UPDATE a table for which a synchronous matchcode is defined.

This means that you cannot update on a statement where there are other tables as a reference or check with the key.

To prove my point i tried this

update eban set banfn = '0010000200'

where banfn eq '0010000000'.

and it did work.

MANDT BANFN BNFPO BSART BSTYP BSAKZ LOEKZ STATU ESTKZ FRGKZ FRGZU FRGST EKGRP ERNAM

200 0010000200 00010 NB B X N B J09 Scheduling

this is the record. So it does update the primary key.

Regards,

Shekhar Kulkarni

Former Member
0 Kudos

Hi,

It is written that "You cannot change the primary key when you UPDATE a table for which a <b>synchronous matchc</b>ode is defined". I suppose that an altenative way is to delete the old values and to insert the new ones.

Svetlin

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

It is possible.

data itab type standard table of zzz_makt.

update zzz_makt set zmatnr = '100' where zmaktx = 'PULSES'.

Here Zmatnr is the primary key in my table zzz_makt.

It is not refering any field.

Vinod_Chandran
Active Contributor
0 Kudos

Hi Anjikumar,

I think when you update the key field(s) of an existing record, you will get a new record with the changed key fields and the record you were trying to update will still exist in table.

Regards

Vinod

Former Member
0 Kudos

Hey,

Are u clarified ??

Inorder to identify a unique row we define Primary key. This promary can be a single key (or) it can be collection of fields.

Important:

It's not possible to change a primary key while updating a table.

Cheers,

Venkat Ramanan