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: 

delete from database ztable using index

Former Member
0 Kudos
408

hi

i want to delte from database table record using index

say for eg i have the index captured in a variable = 8 and i want to delted the 8th record from database

pls suggest how to do it

regards

Nishant

7 REPLIES 7

Former Member
0 Kudos
207

Hi Nishant ,

I dont think you can delete entries from a database table using index , to delete you need to specify the primary key in the where clause.

Regards

Arun

0 Kudos
207

hi

can i modify using index?

or let me know i have data in a table zcust_em and it has only one record which is different from the database table which i want to modify

how to do it?

regards

Nishant

0 Kudos
207

Hi Nishant ,

I dont think there is any operation that can be performed on a data base table uisng index , you will have to use the primary key for it.

I am not sure how you are getting the index of the database table , if you can get it then you can surely also get the primary key fields of the table.

Regards

Arun

0 Kudos
207

hi

i have a database table zmm_aims_opn

with fields

customer number name email

all are primary keys?

i have captured the data in t_modify internal table which contains the data whihc is to be modified

but it is beig inserted not modified as this int table has the modified data hence it is not able to match with the database table and hence it is inserting?

now ther are tow options to use cetain condtion to comapre the record in the d atabase table or use index

index will be better one pls suggest

or let me know if i can use where conditon

or the table zcust_em contains the data which is to be now in the da tabase table how to use this table to update in database?

the modification code is as below

loop at t_aims_opn_modify.

modify zmm_aims_opn from table t_aims_opn_modify ( this is internal table having all records to be modified)

message s001 with 'Data saved'(004).

refresh:t_aims_opn_modify.

endloop.

lse.

message s001 with 'Data already saved'(003).

regards

nishant

0 Kudos
207

Please see my reply to a similar question you have posted,

Regards

Arun

Message was edited by:

Arun R

0 Kudos
207

Hi Nishant,

i think it is the similar thread. Can you please close one thread.

Regards,

Atish

0 Kudos
207

Hi Nishant,

I think this may be ur solution to update a table.

LOOP AT table t_aims_opn_modify .

UPDATE zmm_aims_opn SET email = table t_aims_opn_modify -email

WHERE email EQ table t_aims_opn_modify -email

IF sy-subrc = 0.

COMMIT WORK.

message s001 with 'Data saved'(003

ENDIF.

ENDLOOP.