Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replaces single quote with two single quotes 1

Status
Not open for further replies.

vgowds

Programmer
Jan 20, 2000
1
US
Query which has a single quote runs fine when the exact query is written inside the cfquery tag.<br>
But when the query is built dynamically with a single quote , that is outside the cfquery tag and later on used inside the cfquery tag replaces the single quote with two single quotes.<br>
like<br>
&lt;cfset queryString = &quot;select * from emp where empname='#Jone#'&quot;&gt;<br>
&lt;cfquery name=&quot;checkquery&quot; datasource=&quot;checksource&quot; dbtype=&quot;ODBC&quot;&gt; <br>
#queryString#<br>
&lt;/cfquery&gt;<br>
&lt;cfoutput&gt;#checkquery.group_id#&lt;/cfoutput&gt;<br>
<br>
if this basic query is run it replaces the query string with two single quotes<br>
<br>
select * from emp where empname=''Jone'' {it has two single quotes}<br>
the error is<br>
<br>
ODBC Error Code = 37000 (Syntax error or access violation)<br>
<br>
[Microsoft][ODBC driver for Oracle][Oracle]ORA-00933: SQL command not properly ended<br>
<br>
Data Source = &quot;checksource&quot;<br>
<br>
please send you comments to <A HREF="mailto:kuvind@pnewpda0.tpc.natp.gmeds.com">kuvind@pnewpda0.tpc.natp.gmeds.com</A>
 
Use the PreserveSingleQuotes function:<br>
<br>
&lt;CFQUERY NAME=&quot;get_attybio&quot; DATASOURCE=&quot;web_xxxr&quot;&gt;<br>
SELECT abname, rid, ablast, abfirst FROM attorney<br>
WHERE #PreserveSingleQuotes(searchClause)#<br>
ORDER BY ablast<br>
&lt;/CFQUERY&gt;<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top