I am having difficulty finding a way that will copy a subset of rows from a table stored in Oracle to a GDB.
Here is an example:
Source table contains the following fields - "SCHEDULE_TIME", "ADDRESS", "CITY", "STATE", "ZIP_CODE", "ROUTE_ID", "x", "y"
I am trying to extract all of the records for a route_id in one zip_code.
Here is what I have tried so far:
1. The following code ended up copying the entire table to the GDB.
2. This following code failed during the call to TableToTable_conversion with an error about the source table not having OIDs
The only change is that the where clause has been moved to the TableTable_conversion function.
Here is an example:
Source table contains the following fields - "SCHEDULE_TIME", "ADDRESS", "CITY", "STATE", "ZIP_CODE", "ROUTE_ID", "x", "y"
I am trying to extract all of the records for a route_id in one zip_code.
Here is what I have tried so far:
1. The following code ended up copying the entire table to the GDB.
Code:
strZipCode = "72645"
strRouteId = "C024"
sqlWhereStmt="\"ZIP_CODE\"='{0}' and \"ROUTE_ID\"='{1}'".format(strZipCode, strRouteId)
#MAKE A VIEW OF THE TABLE AND LIMIT THE ROWS BY THE WHERE CLAUSE
arcpy.MakeTableView_management("SourceRoute_T", "SourceRoute_V", sqlWhereStmt)
#COPY THE TABLE BY USING THE VIEW CREATED ABOVE
arcpy.TableToTable_conversion("SourceRoute_V", "C:\\DDT\\Work\\work.gdb", "route_72645C024_T")
The only change is that the where clause has been moved to the TableTable_conversion function.
Code:
strZipCode = "72645"
strRouteId = "C024"
sqlWhereStmt="\"ZIP_CODE\"='{0}' and \"ROUTE_ID\"='{1}'".format(strZipCode, strRouteId)
#MAKE A VIEW OF THE TABLE AND LIMIT THE ROWS BY THE WHERE CLAUSE
arcpy.MakeTableView_management("SourceRoute_T", "SourceRoute_V")
#COPY THE TABLE BY USING THE VIEW CREATED ABOVE
arcpy.TableToTable_conversion("SourceRoute_V", "C:\\DDT\\Work\\work.gdb", "route_72645C024_T", sqlWhereStmt)