I am running Arc 10.3 in a versioned environment. I am attempting to write a simple code that will select service records coming from Oracle CRM to a separate feature class containing only records that meet the SQL definition query that the user will enter. (Both feature classes, the Oracle CRM data and the new feature class CRM1 have the exact same field schema) The definition query will be a select records > than such and such date. I have the basics down but when I enter the SQL where clause it does not select any records.

Below is only the code for selecting out the records, the append part is not yet started as I can't get the select part to work first!

SQL Clause I am using : "REPORTED_DATE" > date '2015-06-13 00:00:00' (REPORTED_DATE is my field in both Oracle CRM and CRM1 that contains my date reported for the service requests)

Pic of my Model -

(source: gislab.net)


# Import system modules
import arcpy
from arcpy import env

# Set workspace
env.workspace = "Z:/Projects/sharedData/SMTEST.gdb/"

# Set local variables
in_features = "Z:/Projects/sharedData/SMTEST.gdb/CRM_ATTACH"
out_feature_class = "z:/Projects/sharedData/SMTEST.gdb/CRM_ATTACH1"
where_clause = raw_input()

# Execute Select
arcpy.Select_analysis(in_features, out_feature_class, where_clause)

1 Answer 1


I would suggest to create a Model in ModelBuilder using the select analysis tool and define a test query in there using the where clause parameter. Once that works you can define the input table/layer, output table/layer, and where clause model objects as model parameter (right click and select Model Parameter) so the user is prompted to fill in this info when the model is run.

After this is working you could export the model to python script to view the proper formatting of the where clause.

  • Could you help explain this a tad more, let me show you what I made in model builder, it seems on the path but it still does not allow the user to select the sql query . here is a link to an image of the model builder i have created tinypic.com/r/qryc6w/8
    – ed.hank
    Commented Jun 17, 2015 at 15:14
  • Can you add the image in your question instead?
    – artwork21
    Commented Jun 17, 2015 at 17:29
  • image added, if you need further information just let me know and I will put up whatever i have
    – ed.hank
    Commented Jun 17, 2015 at 19:29
  • 1
    Looks like you have everything correct, just make the input and output objects model parameters, and then save the model. Next in ArcCatalog, browse to where the model is saved and double click on it to open the model user form.
    – artwork21
    Commented Jun 18, 2015 at 12:43
  • Yup, i did not realize you couldnt run the model from the script screen by hitting the play button (the screen with the validate option) it doesnt seem to load the parameters that way, when I ran it from the ArcToolBox it worked. Thank you for your help!
    – ed.hank
    Commented Jun 19, 2015 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.