AnsweredAssumed Answered

ValueError: Row: Invalid input value for setting - when inserting rows

Question asked by darinatch on Nov 1, 2012
Latest reply on Nov 2, 2012 by jamesfreddyc
Hello everybody,

Here is what I want to do:

   - select data from a SQL Server database, which is not SDE using pyodbc
   - insert the records returned by the select into a table in a geodatabase

I am getting the following error:

***********************************************
Traceback (most recent call last):
  File "E:\Workspace\Warehouse\PythonScripts\PerformSpatialJoins.py", line 80, in <module>
    arcpyRow.YCoord = row.YCoord
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\_base.py", line 35, in __setattr__
    return setattr(self._arc_object, attr, ao)
ValueError: Row: Invalid input value for setting
***********************************************

I understand that it doesn't like the value of the XCoord, but I don't understand why it doesn't like it.
The data type of the XCoord in the SQL Server table is "numeric", and the data type of the XCoord in the geodatabase table is "double". I also tried float and long integer (the coordinates are integer values even if they are in a numeric field). I always get this error. If I don't insert the XCoord and YCoord attributes, the script works as expected.

Any idea is greatly appreciated!

Below is the python script:

# Import arcpy module import arcpy import pyodbc import os  # Set Geoprocessing environments arcpy.env.overwriteOutput = True  DatabaseConnectionString = "Driver={SQL Server Native Client 10.0};SERVER=myserver;DATABASE=mydatabase;Trusted_Connection=yes" LocationsForGISProcessing = "dbo.vw_myview"  ScratchGeodatabasePath = "E:\\Workspace\\Warehouse\\ScratchWorkspace\\Scratch.gdb" TempLocationsForGISProcessing = "LocationsForGISProcessing"   ##################################################################################### # Create ODBC connection    conn = pyodbc.connect(DatabaseConnectionString) cursor = conn.cursor()  print "Connected to database"  ################################################################################## # Insert the data into the geodatabase  TempTable = ScratchGeodatabasePath + "\\" + TempLocationsForGISProcessing      # Process: Delete Rows From Previous Load arcpy.DeleteRows_management(TempTable)  arcpyCursor = arcpy.InsertCursor(TempTable)  cursor.execute("SELECT * FROM " + LocationsForGISProcessing) rows = cursor.fetchall() for row in rows:     arcpyRow = arcpyCursor.newRow()         arcpyRow.Location_Key = row.Location_Key         arcpyRow.From_Date = row.From_Date     arcpyRow.XCoord = row.XCoord     arcpyRow.YCoord = row.YCoord     arcpyCursor.insertRow(arcpyRow)    # Delete the arcypy cursor del arcpyCursor   # Close the connection if (cursor is not None):     cursor.close()     del cursor     if (conn is not None):        conn.close()     del conn 

Outcomes