<?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 ArcSDESQLExecute Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424882#M33347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried to join the three tables and select the records from the table in one of our arcsde database using python scripts, however I got a traceback error indicating "ArcSDESQLExecute: StreamPrepareSQL ArcSDE Error -37 ". I don't have any clue how to fix this error. Interestingly, when I join the two tables and run the query, it works well. Here is the snippet that gives error when run the query for three tables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;try:&lt;BR /&gt; sdeconn = r"Database Connections\Database.sde"&lt;BR /&gt; sql = "SELECT * \&lt;BR /&gt;FROM Table1 \&lt;BR /&gt; JOIN Table2 \&lt;BR /&gt; ON Table2.column1&amp;nbsp;= Table1.column2&amp;nbsp;\&lt;BR /&gt; JOIN Table3 \&lt;BR /&gt; ON Table3.column3 = Table1.column2 \&lt;BR /&gt; WHERE AgriLogger_Table1.column 2 = 3"&lt;BR /&gt; cnn = arcpy.ArcSDESQLExecute(sdeconn)&lt;BR /&gt; sqlresult = cnn.execute(sql)&lt;BR /&gt; for i in sqlresult:&lt;BR /&gt; print i&lt;BR /&gt;except Exception as err:&lt;BR /&gt; print unicode(err.message).encode("utf-8")&lt;BR /&gt; print err&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/216716_pastedImage_206.jpg" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Aug 2016 16:46:39 GMT</pubDate>
    <dc:creator>KushendraShah1</dc:creator>
    <dc:date>2016-08-17T16:46:39Z</dc:date>
    <item>
      <title>ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424882#M33347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried to join the three tables and select the records from the table in one of our arcsde database using python scripts, however I got a traceback error indicating "ArcSDESQLExecute: StreamPrepareSQL ArcSDE Error -37 ". I don't have any clue how to fix this error. Interestingly, when I join the two tables and run the query, it works well. Here is the snippet that gives error when run the query for three tables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;try:&lt;BR /&gt; sdeconn = r"Database Connections\Database.sde"&lt;BR /&gt; sql = "SELECT * \&lt;BR /&gt;FROM Table1 \&lt;BR /&gt; JOIN Table2 \&lt;BR /&gt; ON Table2.column1&amp;nbsp;= Table1.column2&amp;nbsp;\&lt;BR /&gt; JOIN Table3 \&lt;BR /&gt; ON Table3.column3 = Table1.column2 \&lt;BR /&gt; WHERE AgriLogger_Table1.column 2 = 3"&lt;BR /&gt; cnn = arcpy.ArcSDESQLExecute(sdeconn)&lt;BR /&gt; sqlresult = cnn.execute(sql)&lt;BR /&gt; for i in sqlresult:&lt;BR /&gt; print i&lt;BR /&gt;except Exception as err:&lt;BR /&gt; print unicode(err.message).encode("utf-8")&lt;BR /&gt; print err&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/216716_pastedImage_206.jpg" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 16:46:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424882#M33347</guid>
      <dc:creator>KushendraShah1</dc:creator>
      <dc:date>2016-08-17T16:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424883#M33348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the tables you are querying have spatial columns?&amp;nbsp; If so, that is likely throwing the error because arcpy.ArcSDESQLExecute can't work with them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 17:37:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424883#M33348</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-17T17:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424884#M33349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua- There is no spatial columns in any of those tables. It doesn't throw error when join and query two tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 17:55:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424884#M33349</guid>
      <dc:creator>KushendraShah1</dc:creator>
      <dc:date>2016-08-17T17:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424885#M33350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are your table names really "Table1," "Table 2," etc...?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A few comments:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;At some point, you abstract the information enough from reality (e.g., "Table1" instead of actual table name and "Column1" instead of actual column name) that it becomes difficult for people to provide meaningful feedback.&lt;/LI&gt;&lt;LI&gt;It would be helpful to provide more specifics about columns involved?&amp;nbsp; "&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;SELECT *&lt;/SPAN&gt; " is not a good practice, either for developing SQL or troubleshooting it.&amp;nbsp;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;arcpy.ArcSDESQLExecute&lt;/SPAN&gt; doesn't like more than just spatial columns.&amp;nbsp; If you can provide the various data types of columns, it might become apparent if one of the columns is the issue.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;What is the SQL that works?&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 18:56:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424885#M33350</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-17T18:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424886#M33351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the sql that works for two table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt; sdeconn = r"Database Connections\SDataGIS.sde"&lt;BR /&gt; sql = "SELECT * FROM TableLocations JOIN TableMetaData ON TableLocations.LocationID = TableMetaDataDetails.AgriLoggerID&amp;nbsp;WHERE TableMetaDataDetails.AgriLoggerID = 78"&lt;BR /&gt; conn = arcpy.ArcSDESQLExecute(sdeconn)&lt;BR /&gt; sqlresult = conn.execute(sql)&lt;BR /&gt; for i in sqlresult:&lt;BR /&gt; print i&lt;BR /&gt;except Exception as err:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print err&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# when I brought the 3rd table and run this query, it works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 19:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424886#M33351</guid>
      <dc:creator>KushendraShah1</dc:creator>
      <dc:date>2016-08-17T19:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424887#M33352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;# when I brought the 3rd table and run this query, it doesn't not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 19:33:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424887#M33352</guid>
      <dc:creator>KushendraShah1</dc:creator>
      <dc:date>2016-08-17T19:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424888#M33353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to the &lt;A href="http://help.arcgis.com/en/geodatabase/10.0/sdk/arcsde/api/capi/returncodes_incl.htm"&gt;ArcSDE return codes&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;H5 style="color: #000000; text-transform: none; line-height: normal; text-indent: 0px; letter-spacing: normal; padding-left: 30px; font-family: verdana; font-style: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;SE_TABLE_NOEXIST (-37)&lt;/H5&gt;&lt;P&gt;The specified DBMS table does not exist.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you sure the syntax with the 3rd table is correct?&amp;nbsp; Have you tried executing the SQL outside of ArcGIS to see if it returns an error?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 02:18:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424888#M33353</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-18T02:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424889#M33354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried and run outside of ArcGIS and it works well. Actually my 3rd table was not correct(made typo). Also, I used the 3rd table for a feature class, it seems like ArcSDESQL doesn't work for spatial column. I got an error of "ArcSDESQLExecute: StreamBindOutputColumn ArcSDE Error -65". I know some of the columns has null values in them. It would be great if I can perform join in Spatial data not just tables and perform query to extract the information. Thank you so much for getting into this Joshua. I appreciated for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 15:22:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424889#M33354</guid>
      <dc:creator>KushendraShah1</dc:creator>
      <dc:date>2016-08-18T15:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424890#M33355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;arcpy.ArcSDESQLExecute&lt;/SPAN&gt; was not designed to retrieve spatial data.&amp;nbsp; It isn't an issue of NULL or not NULL, it is the fact that one of your columns is an unsupported data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you are using an enterprise DBMS already, you should look into query layers (&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/map/working-with-layers/what-is-a-query-layer-.htm"&gt;What is a query layer?&lt;/A&gt; ).&amp;nbsp; You can write SQL JOIN statements that include spatial columns with query layers.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 15:35:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424890#M33355</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-18T15:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424891#M33356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the info Joshua.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 15:55:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcsdesqlexecute-error/m-p/424891#M33356</guid>
      <dc:creator>KushendraShah1</dc:creator>
      <dc:date>2016-08-18T15:55:55Z</dc:date>
    </item>
  </channel>
</rss>

