Oracle中的單引號和&


對於Oracle中的‘和&,

在sql語句中如果可能出現這些特殊字符,可先查找替換,再拼接sql語句,

例如,在Java中,


<span style="white-space:pre">		</span>String oldStr = "!@#$%^&*()_+[];',./<>?:{}";
		String newStr = "";
		String resultStr = "";
		if(oldStr.contains("'")){
			newStr = oldStr.replaceAll("'", "''");
		}
		if(auditDesc.contains("&")){
			resultStr = newStr.replaceAll("&", "'||'&'||'");
		}


其它關於Oracle中轉義字符、特殊字符的文章:

http://blog.sina.com.cn/s/blog_67be3b450101eora.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章