I am working on a Oracle database. It has a table called USR_INFO and has following columns.
CREATE TABLE ROLE_INFO
INSERT INTO ROLE_INFO (ROLE_ID, ROLE_NAME)
SELECT U_ID, U_NAME
WHERE U_ROLE == "B"
DELETE FROM USR_INFO
WHERE U_ROLE == "B";
You can modify the insert this way to add "BB" to your insert statement (note the single
= instead of
==) . Also replace
'B' in your where clause.
INSERT INTO ROLE_INFO (ROLE_ID, ROLE_NAME , ROLE_TAG) SELECT U_ID, U_NAME,'BB' FROM USR_INFO WHERE U_ROLE='B'; COMMIT; DELETE FROM USR_INFO WHERE U_ROLE='B'; COMMIT;
Since your select statement and the delete statement is checking for the same condition the delete statement will only remove the rows where U_ROLE="B" (please note you need to use single equals as well).
Also once you perform the insert statement, you need to issue a commit statement so that the changes are persisted and visible.