当用户在用 C# (.NET) 开发的表单条目中输入诸如“Sam 的项目可交付成果”之类的输入文本时,我想转义单引号。数据库是ORACLE 10g。
我遇到了 ORACLE 10g http://www.orafaq.com/wiki/SQL_FAQ#How_does_one_escape_special_characters_when_writing_SQL_queries.3F提供的引号分隔符功能,但我不确定是否使用这样的引号分隔符q'[ some text with single quote]'作为一部分一个 SELECT 语句会阻止 SQL 注入攻击吗?
引号分隔符 q'[ 带单引号的文本 ]' 的示例用法:
SQL> SELECT q'[Frank's Oracle site]' AS text FROM DUAL;
TEXT
-------------------
Frank's Oracle site
SQL> SELECT q'[A 'quoted' word.]' AS text FROM DUAL;
TEXT
----------------
A 'quoted' word.
SQL> SELECT q'[A ''double quoted'' word.]' AS text FROM DUAL;
TEXT
-------------------------
A ''double quoted'' word.