AnsweredAssumed Answered

Arcpy - execute sql query in oracle error

Question asked by Pi-Hellz on Nov 19, 2014
Latest reply on Nov 20, 2014 by jamesfreddyc


Hi,

 

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.

 

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 :

 

Error_Rows.JPG

I tried to put  rows = cursor.fetchall() in my if statement and it doesn't work either.

The line 75 refer to the line in red

 

if rdc == True:

    sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC" + arg1

    cursor.execute(sql)

   

else:

    sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES WHERE " + arg1

    cursor.execute(sql)

 

rows = cursor.fetchall() 

 

avec_rdc = (row for row in rows if rdc == True)

sans_rdc = (row for row in rows if rdc == False)

 

for row in avec_rdc:

        trow = iCur.newRow()

        trow.INCIDENT_N = row[0]

        trow.DATE_INTER = row[2]

        trow.ADRESSE_IN = row[3]

        trow.TYPE_INT = row[4]

        trow.CAS_NO = row[5]

        trow.REGION = row[6]

        trow.CATEGORIE = row[7]

        trow.SITE_KEY = row[8]

        trow.ARRONDISSE = row[9]

        trow.LISTE_UNIT = row[11]

        trow.LONGITUDE = row[12]

        trow.LATITUDE = row[13]

 

for row in sans_rdc:

        trow = iCur.newRow()

        trow.INCIDENT_N = row[0]

        trow.DATE_INTER = row[1]

        trow.ADRESSE_IN = row[2]

        trow.TYPE_INT = row[3]

        trow.CAS_NO = row[4]

        trow.REGION = row[5]

        trow.CATEGORIE = row[6]

        trow.SITE_KEY = row[7]

        trow.ARRONDISSE = row[8]

        trow.LISTE_UNIT = row[9]

        trow.LONGITUDE = row[10]

        trow.LATITUDE = row[11]

 

iCur.insertRow(trow)

 

thanks for your help

Outcomes