I there a particular reason to use StringBuilder here (performance?!?). I think `value => Option(value).map( "'" + _.replace("'","''") + "'" ).getOrElse("NULL")` would be more readable.