I’m building a dml file that first deletes records that may be in the table, then inserts records.
Example:
DELETE from foo where field1='bar';
DELETE from foo where fields1='bazz';
INSERT ALL
INTO foo(field1, field2) values ('bar', 'x')
INTO foo(field1, field2) values ('bazz', 'y')
SELECT * from DUAL;
When I run the insert statement by itself, it runs fine. When I run the deletes, only the last delete runs.
Also, it seems to be necessary to end the multiple insert with the select, is that so? If so, why is that necessary?
In the past, when using MySQL, I could just list multiple delete and insert statements, all individually ending with a semicolon, and it would run fine.
You apparently have a typo, since you’re calling it either
field1orfields1in the DELETEs.You’re doing it the hard way, though.
Not sure if Oracle requires the
FROM System.dual, although I seem to recall it did. SQL Server will allow just aSELECT 'bar', 'x'instead.