public static String quoteStringSQL(String s) {
		if (s == null) {
			return "NULL";
		}
		int length = s.length();
		StringBuilder buff = new StringBuilder(length + 2);
		buff.append('\'');
		for (int i = 0; i < length; i++) {
			char c = s.charAt(i);
			if (c == '\'') {
				buff.append(c);
			} else if (c < ' ' || c > 127) {
				// need to start from the beginning because maybe there was a \
				// that was not quoted
				return "STRINGDECODE(" + quoteStringSQL(javaEncode(s)) + ")";
			}
			buff.append(c);
		}
		buff.append('\'');
		return buff.toString();
	}