wtgeographer

Create SQL STatement

Discussion created by wtgeographer on Apr 3, 2014
Can somebody tell me how to use the following to effectively call on create sql function using paramters 0-9 below:

Thanks in advance,

def isNumber(value):
    try: Decimal(value)
    except: return False
    return True

def createSQL(source, field, value):
    if not isNumber(value): value = "'%s'" % value
    return '{0} = {1}'.format(arcpy.AddFieldDelimiters(source, field), value)

def main():
    subs  = arcpy.GetParameterAsText(0)
    Field = arcpy.GetParameterAsText(1)
    originValue = arcpy.GetParameterAsText(2)
    destValue   = arcpy.GetParameterAsText(3)
    lines = arcpy.GetParameterAsText(4)
    Dem = arcpy.GetParameterAsText(5)
    landuseRaster = arcpy.GetParameterAsText(6)
    savepath = arcpy.GetParameterAsText(7)
    arcpy.SetParameterAsText(8, createSQL(subs, Field, originValue))
    arcpy.SetParameterAsText(9, createSQL(subs, Field, destValue))

Outcomes