ns_dbquotevalue prepares a value string for inclusion in an SQL statement. The value is of type text by default. Values of a numeric type in the value string are left alone. A value string of "" is translated into NULL. All other values are surrounded by single quotes, and any single quotes included in the value are escaped (translated into two single quotes).
set value "Charlie's Cheese Factory" ns_db dml $db \ "insert into companies(name) values ([ns_dbquotevalue $value])"