Given that it is stored in a procedure, why is it bothering you, is this one or two INSERT statements? Clearly, the two statements are trivial.
Some DBMSs allow you to list multiple value sentences in one INSERT (@Ivan suggests this):
INSERT INTO Table(ID, ContactName, Designation) VALUES(1, @ContactName1, @Designation1) VALUES(1, @ContactName2, @Designation2);
I am not sure if a comma is needed between the lists of values. I also donβt understand whether two records in the table are allowed to have the same identifier, as well as how the identifier is determined - this is probably some kind of material with automatic increment, and different DBMSs also do this.
If your DBMS does not support multiple VALUES clauses in a single INSERT statement, you would be better off not accepting two INSERT statements. If atomicity is a problem, you can consider transactions, although if it is only part of a larger transaction, ROLLBACK on error, in particular, will be a problem. If your DBMS supports SAVEPOINTS, then the procedure can set a save point at input and commit or cancel saving at the save point at exit.
source share