<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Arcpy - execute sql query in oracle error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289472#M22431</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi thank for all your answers !!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It was kind of my first python script so i'm open to fix it to optimize my code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;James is right i'm using cx_Oracle for my connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here what my sql query look likes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164926729962337" jivemacro_uid="_14164926729962337"&gt;
&lt;P&gt;SELECT * FROM INTERVENTIONS_GEO_UNITES WHERE TYPE_INT &amp;lt;&amp;gt; '1ERREP' and DATE_INTER BETWEEN TO_DATE('01/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS')&amp;nbsp; AND TO_DATE('12/31/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS') and ARRONDISSEMENT_VILLE in ('Côte-des-Neiges--Notre-Dame-de-Grâce','Plateau-Mont-Royal','Outremont')&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or if it with rdc here my query pratically the same except they add a suffix RDC at the view name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1416492950030836 jive_text_macro" jivemacro_uid="_1416492950030836"&gt;
&lt;P&gt;SELECT * FROM INTERVENTIONS_GEO_UNITES&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;_RDC&lt;/STRONG&gt;&lt;/SPAN&gt; WHERE TYPE_INT &amp;lt;&amp;gt; '1ERREP' and DATE_INTER BETWEEN TO_DATE('01/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS')&amp;nbsp; AND TO_DATE('12/31/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS') and ARRONDISSEMENT_VILLE in ('Côte-des-Neiges--Notre-Dame-de-Grâce','Plateau-Mont-Royal','Outremont')&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I don't understand is that i can execute the script without any problems when I don't have the condition True or False with this code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164931446737004" jivemacro_uid="_14164931446737004"&gt;
&lt;P&gt;sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES WHERE " + arg1&lt;/P&gt;
&lt;P&gt;cursor.execute(sql)&lt;/P&gt;
&lt;P&gt;rows = cursor.fetchall()&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll try the differents options that you guys gave me and come back for the feedback of my tests&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Nov 2014 14:23:39 GMT</pubDate>
    <dc:creator>Pierre-LucBoivin</dc:creator>
    <dc:date>2014-11-20T14:23:39Z</dc:date>
    <item>
      <title>Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289466#M22425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164131786672344" jivemacro_uid="_14164131786672344"&gt;
&lt;P&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to execute a sql query from an oracle table but the problem is that according to a new argument that is true, I have to make a connection to another table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My original script that i've been using for 2 years works like a charm so I just add an if statement in the connection variable but when comes the time to populate my temp table I got this error :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="31533" alt="Error_Rows.JPG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/31533_Error_Rows.JPG" style="width: 620px; height: 33px;" /&gt;&lt;/P&gt;&lt;P&gt;I tried to put&amp;nbsp; rows = cursor.fetchall() in my if statement and it doesn't work either.&lt;/P&gt;&lt;P&gt;The line 75 refer to the line in red&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;if rdc == True:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC" + arg1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.execute(sql)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;else:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES WHERE " + arg1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.execute(sql)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;rows = cursor.fetchall()&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;avec_rdc = (row for row in rows if rdc == True)&lt;/P&gt;
&lt;P&gt;sans_rdc = (row for row in rows if rdc == False)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;for row in avec_rdc&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow = iCur.newRow()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.INCIDENT_N = row[0]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.DATE_INTER = row[2]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.ADRESSE_IN = row[3]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.TYPE_INT = row[4]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.CAS_NO = row[5]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.REGION = row[6]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.CATEGORIE = row[7]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.SITE_KEY = row[8]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.ARRONDISSE = row[9]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.LISTE_UNIT = row[11]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.LONGITUDE = row[12]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.LATITUDE = row[13]&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for row in sans_rdc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow = iCur.newRow()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.INCIDENT_N = row[0]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.DATE_INTER = row[1]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.ADRESSE_IN = row[2]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.TYPE_INT = row[3]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.CAS_NO = row[4]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.REGION = row[5]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.CATEGORIE = row[6]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.SITE_KEY = row[7]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.ARRONDISSE = row[8]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.LISTE_UNIT = row[9]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.LONGITUDE = row[10]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trow.LATITUDE = row[11]&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;iCur.insertRow(trow)&lt;/P&gt;

&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 16:05:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289466#M22425</guid>
      <dc:creator>Pierre-LucBoivin</dc:creator>
      <dc:date>2014-11-19T16:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289467#M22426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Total guess here, but "rows" is empty. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the value of "arg1"?&amp;nbsp; If it's numeric, you may&amp;nbsp; need to convert it to string, as well as add an extra space after the SELECT statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164223782692269" jivemacro_uid="_14164223782692269"&gt;
&lt;P&gt;sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC " + str(arg1)&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 18:39:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289467#M22426</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-11-19T18:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289468#M22427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Probably of more importance.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get rid of the "SELECT *" !!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am of the mind that it's just silly to have this in any production environment.&amp;nbsp; I see you have the fields listed out for your cursor, it's probably even more important to have them listed in your SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 18:48:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289468#M22427</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-11-19T18:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289469#M22428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax highlighting is having a dang fit so I did a pastbin of what I think would work. &lt;A href="http://paste.pound-python.org/show/nnwkcPiRJshsKg0vgr0J/" title="http://paste.pound-python.org/show/nnwkcPiRJshsKg0vgr0J/"&gt;Paste #nnwkcPiRJshsKg0vgr0J at spacepaste&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its also not a good idea to use fetchall() generally. If you know you're getting a small result set its OK but because the entire result is being read into memory your can run into problems. Better to do something like what is below. Its wordier but it keeps your memory usage down.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164262583787775" jivemacro_uid="_14164262583787775" modifiedtitle="true"&gt;
&lt;PRE ___default_attr="python" _jivemacro_uid="_14164262607192385" _modifiedtitle="true" class="jive_macro_code jive_text_macro _jivemacro_uid_14164262607192385"&gt;
&lt;P&gt;while True:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cursor.fetchone()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row == None:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if rdc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; avec_rdc.append(row)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sans_rdc.append(row)&lt;/P&gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 19:45:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289469#M22428</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2014-11-19T19:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289470#M22429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with &lt;A href="https://community.esri.com/migrated-users/7306"&gt;James Crandall&lt;/A&gt;‌ about SELECT * .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you using pyodbc?&amp;nbsp; If so, fetchall() returns an empty list, even if no rows are returned, so I don't get why rows wouldn't be defined.&amp;nbsp; If a successful query, even one with no results, returns a list that could instantiate rows; maybe the queries are generating an error and fetchall is returning nothing, so rows doesn't exist.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 19:56:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289470#M22429</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2014-11-19T19:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289471#M22430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OP is probably using cx_Oracle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 13:49:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289471#M22430</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-11-20T13:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289472#M22431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi thank for all your answers !!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It was kind of my first python script so i'm open to fix it to optimize my code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;James is right i'm using cx_Oracle for my connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here what my sql query look likes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164926729962337" jivemacro_uid="_14164926729962337"&gt;
&lt;P&gt;SELECT * FROM INTERVENTIONS_GEO_UNITES WHERE TYPE_INT &amp;lt;&amp;gt; '1ERREP' and DATE_INTER BETWEEN TO_DATE('01/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS')&amp;nbsp; AND TO_DATE('12/31/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS') and ARRONDISSEMENT_VILLE in ('Côte-des-Neiges--Notre-Dame-de-Grâce','Plateau-Mont-Royal','Outremont')&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or if it with rdc here my query pratically the same except they add a suffix RDC at the view name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1416492950030836 jive_text_macro" jivemacro_uid="_1416492950030836"&gt;
&lt;P&gt;SELECT * FROM INTERVENTIONS_GEO_UNITES&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;_RDC&lt;/STRONG&gt;&lt;/SPAN&gt; WHERE TYPE_INT &amp;lt;&amp;gt; '1ERREP' and DATE_INTER BETWEEN TO_DATE('01/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS')&amp;nbsp; AND TO_DATE('12/31/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS') and ARRONDISSEMENT_VILLE in ('Côte-des-Neiges--Notre-Dame-de-Grâce','Plateau-Mont-Royal','Outremont')&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I don't understand is that i can execute the script without any problems when I don't have the condition True or False with this code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164931446737004" jivemacro_uid="_14164931446737004"&gt;
&lt;P&gt;sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES WHERE " + arg1&lt;/P&gt;
&lt;P&gt;cursor.execute(sql)&lt;/P&gt;
&lt;P&gt;rows = cursor.fetchall()&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll try the differents options that you guys gave me and come back for the feedback of my tests&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 14:23:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289472#M22431</guid>
      <dc:creator>Pierre-LucBoivin</dc:creator>
      <dc:date>2014-11-20T14:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - execute sql query in oracle error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289473#M22432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The difference is that you fixed the sql:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC " + arg1&lt;SPAN class="string"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before you had it without any space between the sql string&amp;nbsp; and your arg1 value (there was no space between the RDC and the last quote):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC" + arg1&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 16:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-execute-sql-query-in-oracle-error/m-p/289473#M22432</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-11-20T16:36:05Z</dc:date>
    </item>
  </channel>
</rss>

