Application Development and Automation 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: 
Read only

Update Table

Former Member
0 Likes
494

In program using two tables A & B. The table A has more than one records for a given employee No. while Table B has only single record.

First a single record is picked from Table A & compared with Table B. IF it matches all the records of Table A for that employee No should get updated which includes primary key fields also.

This has been in a loop where single record of Table A is updated using

UPdate table A set field where condition.

Is there any other faster way of doing this so that all the records can be updated collectively in Table A.

Please guide

thanks

anu

4 REPLIES 4
Read only

dani_mn
Active Contributor
0 Likes
458

The number of record updation depends on the the where condition you have mention if it matches more than one record than more than one record will be updated.

and if you want to change primary key fields also then 'UPDATE' will not work and you have to delete record first and then insert it with new keys.

Regards,

Wasim Ahmed

Read only

Former Member
0 Likes
458

hi

as mentioned by u ...dont think primary key can be updated as it's against DB concepts and data consistency:

but updating table mostly depends on the where clause u are using and move it to songle internal table and make sure the type of the internal table is same as the structure of the DB table ...

and say modify dbtable from internal table...

regards

gunjan

Read only

Former Member
0 Likes
458

wasim,

the data base table is getting updated where ever the condition is matching. Its also changing the primary key fields. Actually requirement is to change only few primary fields not all the key fields.

thanks

anu

Read only

0 Likes
458

hi Anupma,

Key fields can't be changed with update or modify command. then how your table is updating i don't understand.

Well its very simple if you want to change few key fields get your values in an internal table from database table and delete these values from database table. now change the fields that you want to change in internal table using loop endloop. modify.

And then insert these changes values back into database table using 'INSERT' OR 'MODIFY'.

Regards,

Wasim Ahmed