fixed INSERT error message and improved general case (c.f. Issue #771)