Check to avoid select statement in case of empty insert