scandalous
scandalous

Reputation: 912

Delete statement after executing a SQL insert twice

From an Oracle database, I have executed an insert SQL statement twice in a production environment.

Sadly, the rollback option did not seem to work.

The insert statement was:

INSERT INTO MAE_INT.T_INT_APPLICATION (INAP_IDENT, INAP_PARAM, INAP_VALEUR, INAP_DATE) 
VALUES ((SELECT MAX(INAP_IDENT)+1 FROM MAE_INT.T_INT_APPLICATION), 'monitoring', 'true', '10/06/2016');

COMMIT;

I guess the only option now is to make a delete statement for the double.

Anyone can help with that? Not sure how to write it

Upvotes: 0

Views: 351

Answers (1)

Utsav
Utsav

Reputation: 8093

You can delete max(INAP_IDENT) like below, thereby leaving you with first insert statement only.

NOTE: TEST IT IN DEV/UAT ENVIRONMENT FIRST

delete from MAE_INT.T_INT_APPLICATION
where INAP_IDENT=
 (SELECT MAX(INAP_IDENT) FROM MAE_INT.T_INT_APPLICATION);

Before committing, check if you dont have duplicate entry.

Upvotes: 1

Related Questions