07-25-2005 12:51 PM
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
07-25-2005 1:02 PM
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
07-25-2005 12:59 PM
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
07-25-2005 1:07 PM
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
07-25-2005 1:02 PM
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
07-25-2005 1:03 PM
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.
07-25-2005 1:08 PM
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
07-25-2005 1:57 PM
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