AnsweredAssumed Answered

ArcSDESQLExecute Error

Question asked by kshah77 on Aug 17, 2016
Latest reply on Aug 18, 2016 by kshah77

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:


import arcpy
sdeconn = r"Database Connections\Database.sde"
sql = "SELECT * \
FROM Table1 \
JOIN Table2 \
ON Table2.column1 = Table1.column2 \
JOIN Table3 \
ON Table3.column3 = Table1.column2 \
WHERE AgriLogger_Table1.column 2 = 3"
cnn = arcpy.ArcSDESQLExecute(sdeconn)
sqlresult = cnn.execute(sql)
for i in sqlresult:
print i
except Exception as err:
print unicode(err.message).encode("utf-8")
print err