<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting Error in my where clause using cursor in arcpy. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1088107#M62054</link>
    <description>&lt;P&gt;Sir&amp;nbsp;@Anonymous User&amp;nbsp;. I'm getting my output for the same. But in case of Measured length &amp;amp; Installation Date, I'm getting the multiple values. See, in the case of Measured Length, I'm getting the 5 output values where as in case of Installation Date, I'm getting 2 values. So do i have to change the signs in the where clause? or something else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Material: 5 OPERATINGPRESSURE: 40.0 MEASUREDLENGTH: 182.36985383 INSTALLATIONDATE: 1955-01-01 00:00:00&lt;BR /&gt;1.5&lt;BR /&gt;0.4&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;MEASUREDLENGTHUPPERLIMIT &amp;gt;= 182.36985383&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;0.1&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;0.2&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;0.3&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;0.4&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;1.0&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;INSTALLATIONDATELOWERLIMIT &amp;lt;= timestamp '1955-01-01 00:00:00' and INSTALLATIONDATEUPPERLIMIT &amp;gt;= timestamp '1955-01-01 00:00:00'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;2.0&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;1.4&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Aug 2021 19:48:02 GMT</pubDate>
    <dc:creator>broy06</dc:creator>
    <dc:date>2021-08-11T19:48:02Z</dc:date>
    <item>
      <title>Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086907#M61962</link>
      <description>&lt;P&gt;I'm currently using Arcmap 10.7 version. I'm guessing my error is in the where clause. Could anyone please help me to get rid from this problem?. I'm not able to print the cursor part i.e.,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Print (MEASUREDLENGTH_Risk_Score) # Not getting the value of MEASUREDLENGTH&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code-:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; arcpy
arcpy.env.workspace = &lt;SPAN class="hljs-string"&gt;"D:\pipe\map.gdb"&lt;/SPAN&gt;
featureClass_1 = &lt;SPAN class="hljs-string"&gt;"P_Pipes"&lt;/SPAN&gt;
Table_Pipe = &lt;SPAN class="hljs-string"&gt;"Pipe_Risk"&lt;/SPAN&gt;
fieldNames_1 = [ &lt;SPAN class="hljs-string"&gt;"Material"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTH"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATE"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"Risk_Score"&lt;/SPAN&gt;]
fieldNames_Pipe = [&lt;SPAN class="hljs-string"&gt;"Material"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTHLOWERLIMIT"&lt;/SPAN&gt; ,&lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTHUPPERLIMIT"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATELOWERLIMIT"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATEUPPERLIMIT"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OVERALLRISKSCORE"&lt;/SPAN&gt;]


&lt;SPAN class="hljs-keyword"&gt;def&lt;/SPAN&gt; &lt;SPAN class="hljs-title function_"&gt;Pipe_Risk_Score&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Material, OPERATINGPRESSURE, MEASUREDLENGTH,  INSTALLATIONDATE&lt;/SPAN&gt;):

    ML_Out_fields = [&lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTHLOWERLIMIT"&lt;/SPAN&gt; ,&lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTHUPPERLIMIT"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OVERALLRISKSCORE"&lt;/SPAN&gt;]
    ML_where_Clause = &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTHLOWERLIMIT &amp;lt;= "&lt;/SPAN&gt; + MEASUREDLENGTH + " &lt;SPAN class="hljs-keyword"&gt;and&lt;/SPAN&gt; &lt;SPAN class="hljs-string"&gt;MEASUREDLENGTHUPPERLIMIT &amp;gt;= "&lt;/SPAN&gt; + MEASUREDLENGTH 
    &lt;SPAN class="hljs-built_in"&gt;print&lt;/SPAN&gt;(ML_where_Clause)
    
    Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ML_Out_fields, ML_where_Clause)
    &lt;SPAN class="hljs-keyword"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="hljs-keyword"&gt;in&lt;/SPAN&gt; Table_Pipe_Cursor:
        lst.append(row[&lt;SPAN class="hljs-number"&gt;2&lt;/SPAN&gt;])
        MEASUREDLENGTH_Risk_Score = row[&lt;SPAN class="hljs-number"&gt;2&lt;/SPAN&gt;]
        &lt;SPAN class="hljs-built_in"&gt;print&lt;/SPAN&gt; ((MEASUREDLENGTH_Risk_Score))

Pipe_Risk_Score(&lt;SPAN class="hljs-string"&gt;"Material"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTH"&lt;/SPAN&gt; ,  &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATE"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 08:38:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086907#M61962</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-09T08:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086913#M61963</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/select-layer-by-attribute.htm" target="_blank"&gt;Select Layer By Attribute (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;from there, this is an example of a where clause for a string&lt;/P&gt;&lt;P&gt;"[NAME] = 'California'"&lt;/P&gt;&lt;P&gt;What do you get if you do an sql query on the data manually?&amp;nbsp; Check it out and copy the syntax&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 09:37:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086913#M61963</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-08-08T09:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086918#M61964</link>
      <description>&lt;P&gt;It looks like you are trying to use string formatting for the variable but forgot the .format().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ML_where_Clause = "MEASUREDLENGTHLOWERLIMIT &amp;lt;= {0} and MEASUREDLENGTHUPPERLIMIT &amp;gt;= {0}".format(MEASUREDLENGTH)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 12:02:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086918#M61964</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-08T12:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086919#M61965</link>
      <description>&lt;P&gt;Sir, this statement gives me a blank screen with no output.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 12:28:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086919#M61965</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-08T12:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086920#M61966</link>
      <description>&lt;P&gt;You are passing "MEASUREDLENGTH" as a string variable to MEASUREDLENGTH in the function call, but are trying to use it as integer in the whereclause.&amp;nbsp; Where is the actual value of MEASUREDLENGTH for the sql coming from?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 13:03:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086920#M61966</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-08T13:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086924#M61967</link>
      <description>&lt;P&gt;Yes. See, basically there is 1 feature class &amp;amp; 1 lookup table (Created in a same gdb). The actual value of "MEASUREDLENGTH" is in feature class attributes. but i have assigned some score for the same in the form of range in look up table and now i am calling it from the lookup table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 14:24:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1086924#M61967</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-08T14:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087024#M61969</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Change&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt; + and "MEASUREDLENGTHUPPERLIMIT &amp;gt;= "&lt;/LI-CODE&gt;&lt;P&gt;to&lt;/P&gt;&lt;LI-CODE lang="python"&gt; + " and MEASUREDLENGTHUPPERLIMIT &amp;gt;= "&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 Aug 2021 06:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087024#M61969</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-08-09T06:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087027#M61970</link>
      <description>&lt;P&gt;Hello, Earlier i tried using the same method which you suggested me but getting no output only able to see the print statement of where clause, not getting the value of "MEASUREDLENGTH" which has a double data type values, which i want. Please suggest me, what i'm lacking of?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 08:37:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087027#M61970</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-09T08:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087052#M61979</link>
      <description>&lt;P&gt;You are passing strings into your functions:&lt;/P&gt;&lt;PRE&gt;Pipe_Risk_Score(&lt;SPAN class="hljs-string"&gt;"Material"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTH"&lt;/SPAN&gt; ,  &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATE"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="hljs-string"&gt;OPERATINGPRESSURE&lt;/SPAN&gt; is assigned &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hljs-string"&gt;MEASUREDLENGTH is assigned "MEASUREDLENGTH"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hljs-string"&gt;INSTALLATIONDATE is assigned "INSTALLATIONDATE"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you want the float / date that is assigned to MEASUREDLENGTH (or any of the other values), you need to remove the quotes in the function call so it passes the variables and not &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTH"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATE"&lt;/SPAN&gt; strings. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;OPERATINGPRESSURE = 36

MEASUREDLENGTH = 12

INSTALLATIONDATE = datetime.strptime('08/03/2021 12:43:34')

Pipe_Risk_Score(Material, OPERATINGPRESSURE, MEASUREDLENGTH,  INSTALLATIONDATE)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hljs-string"&gt;OPERATINGPRESSURE&lt;/SPAN&gt; is assigned &lt;SPAN class="hljs-string"&gt;36&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hljs-string"&gt;MEASUREDLENGTH is assigned 12&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hljs-string"&gt;INSTALLATIONDATE is assigned datetime 08/03/2021 12:43:34&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We cant tell how you are assigning the variables from the lookup table from the code snippet you provided above so if you are having issues, it would be helpful to post the full code and any error messages that you are getting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 11:40:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087052#M61979</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-09T11:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087094#M61986</link>
      <description>&lt;P&gt;Sir, Actually while calling a function without "Material" (quotes) , it's showing me "Name error", Name: Material is not defined and so on. okay I'm updating my full code in the question along with the lookup table &amp;amp; feature class attribute pic.&amp;nbsp; Thank you, Please have a look&amp;nbsp; then.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Error:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pipe_Risk_Score("Material" , "OPERATINGPRESSURE" , "MEASUREDLENGTH" , INSTALLATIONDATE)&lt;BR /&gt;NameError: name 'INSTALLATIONDATE' is not defined&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 14:07:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087094#M61986</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-09T14:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087126#M61988</link>
      <description>&lt;P&gt;You are not assigning a value to the variable named INSTALLATIONDATE before you try to pass it into the function.&amp;nbsp; Using "" is falsely working because you are simply passing strings &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTH"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATE"-&amp;nbsp; but that is not passing the data (floats, dates) that you think it is.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Assign a value to the variable INSTALLATIONDATE first, before passing it to the function as the parameter such as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;INSTALLATIONDATE = datetime.strptime('2012-02-10', '%Y-%m-%d')

Pipe_Risk_Score("Material" , "OPERATINGPRESSURE" , "MEASUREDLENGTH" , INSTALLATIONDATE)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will not get the Name Error. You need to do this for each parameter in your function call if you don't want the string, or else you will get the same false positive, which will not work in any sql query within the function since it is not the data (floats, dates).&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 15:20:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087126#M61988</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-09T15:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087226#M61994</link>
      <description>&lt;P&gt;Hi sir, As you have defined or initialize value for a variable like&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;OPERATINGPRESSURE = 36&lt;/PRE&gt;&lt;PRE&gt;MEASUREDLENGTH = 12

INSTALLATIONDATE = datetime.strptime('08/03/2021 12:43:34')

Pipe_Risk_Score(Material, OPERATINGPRESSURE, MEASUREDLENGTH,  INSTALLATIONDATE)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, how should I define my values for the variable in a function call, since each variable has so many different values from the table? How to fetch the data for each variable from a lookup table. Please have a look at the table given below-:&amp;nbsp; &amp;nbsp;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 19:23:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087226#M61994</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-09T19:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087230#M61996</link>
      <description>&lt;P&gt;Use a search cursor to iterate over the table.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Material = 'Something'
with arcpy.da.SearchCursor(yourtable, ["OPERATINGPRESSURE" , "MEASUREDLENGTH" , "INSTALLATIONDATE"]) as sCur:
    for row in sCur:
         OPERATINGPRESSURE = row[0]
         MEASUREDLENGTH = row[1]
         INSTALLATIONDATE = row[2]
         Pipe_Risk_Score(Material, OPERATINGPRESSURE, MEASUREDLENGTH, INSTALLATIONDATE)
         # or 
         # Pipe_Risk_Score(Material, row[0], row[1], row[2])
 &lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 Aug 2021 19:27:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087230#M61996</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-09T19:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087357#M61997</link>
      <description>&lt;P&gt;Sir, Actually i want the average of all these function at last in a return. Please have a look at my full code. I'm interested in accessing the "overallrisk" score of the value of all these parameters like Material, OPERATINGPRESSURE and so on.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; arcpy
arcpy.env.workspace = &lt;SPAN class="hljs-string"&gt;"D:\pipe\map.gdb"&lt;/SPAN&gt;
featureClass_1 = &lt;SPAN class="hljs-string"&gt;"P_Pipes"&lt;/SPAN&gt;
Table_Pipe = &lt;SPAN class="hljs-string"&gt;"Pipe_Risk"&lt;/SPAN&gt;
fieldNames_1 = [ &lt;SPAN class="hljs-string"&gt;"Material"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTH"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATE"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"Risk_Score"&lt;/SPAN&gt;]
fieldNames_Pipe = [&lt;SPAN class="hljs-string"&gt;"Material"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OPERATINGPRESSURE"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTHLOWERLIMIT"&lt;/SPAN&gt; ,&lt;SPAN class="hljs-string"&gt;"MEASUREDLENGTHUPPERLIMIT"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATELOWERLIMIT"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"INSTALLATIONDATEUPPERLIMIT"&lt;/SPAN&gt; , &lt;SPAN class="hljs-string"&gt;"OVERALLRISKSCORE"&lt;/SPAN&gt;]


&lt;SPAN class="hljs-keyword"&gt;def&lt;/SPAN&gt; &lt;SPAN class="hljs-title function_"&gt;Pipe_Risk_Score&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Material, OPERATINGPRESSURE, MEASUREDLENGTH,  INSTALLATIONDATE):&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;# Case: Material&lt;/P&gt;&lt;P&gt;#Material_Out_fields = ["Material" , "OVERALLRISKSCORE"]&lt;BR /&gt;&lt;BR /&gt;Material_where_Clause = "Material = " + Material&lt;BR /&gt;Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ["Material" , "OVERALLRISKSCORE"],Material_where_Clause)&lt;BR /&gt;for row in Table_Pipe_Cursor:&lt;BR /&gt;# lst.append(row[1])&lt;BR /&gt;Material_Risk_Score = row[1]&lt;BR /&gt;print Material_Risk_Score&lt;/P&gt;&lt;P&gt;# Case: Operating Pressure&lt;/P&gt;&lt;P&gt;OP_Out_fields = ["OPERATINGPRESSURE" , "OVERALLRISKSCORE"]&lt;BR /&gt;OP_where_Clause = "OPERATINGPRESSURE = " + OPERATINGPRESSURE&lt;BR /&gt;Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, OP_Out_fields, OP_where_Clause)&lt;/P&gt;&lt;P&gt;for row in Table_Pipe_Cursor:&lt;BR /&gt;lst.append(row[1])&lt;BR /&gt;OPERATINGPRESSURE_Risk_Score = row[1]&lt;BR /&gt;print (OPERATINGPRESSURE_Risk_Score)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Case: ML&lt;/P&gt;&lt;P&gt;ML_Out_fields = ["MEASUREDLENGTHLOWERLIMIT" ,"MEASUREDLENGTHUPPERLIMIT" , "OVERALLRISKSCORE"]&lt;BR /&gt;ML_where_Clause = "MEASUREDLENGTHLOWERLIMIT &amp;lt;= " + MEASUREDLENGTH + " and MEASUREDLENGTHUPPERLIMIT &amp;gt;= " + MEASUREDLENGTH #.format(MEASUREDLENGTH)&lt;BR /&gt;print ML_where_Clause&lt;BR /&gt;#Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ML_Out_fields, ML_where_Clause)&lt;BR /&gt;#ML_where_Clause = "MEASUREDLENGTHLOWERLIMIT &amp;lt;= " + MEASUREDLENGTH + " and MEASUREDLENGTHUPPERLIMIT &amp;gt;= " + MEASUREDLENGTH.format(MEASUREDLENGTH, MEASUREDLENGTH)&lt;BR /&gt;# print(ML_where_Clause)&lt;BR /&gt;#ML_where_Clause = "CAST(MEASUREDLENGTHUPPERLIMIT AS INTEGER &amp;lt;= "MEASUREDLENGTHUPPERLIMIT" and "MEASUREDLENGTHUPPERLIMIT" &amp;gt;= "MEASUREDLENGTHLOWERLIMITTable_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ML_Out_fields, ML_where_Clause)&lt;/P&gt;&lt;P&gt;"""for row in Table_Pipe_Cursor:&lt;BR /&gt;lst.append(row[2])&lt;BR /&gt;MEASUREDLENGTH_Risk_Score = row[2]&lt;BR /&gt;print MEASUREDLENGTH_Risk_Score"""&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Case: ID&lt;/P&gt;&lt;P&gt;#INSTALLATIONDATE = datetime.strptime("01/01/1935 00:00:00" , "01/01/2035 00:00:00")&lt;BR /&gt;#ID_Out_fields = ["INSTALLATIONDATELOWERLIMIT" , "INSTALLATIONDATEUPPERLIMIT" , "OVERALLRISKSCORE"]&lt;BR /&gt;#ID_where_Clause = "INSTALLATIONDATELOWERLIMIT &amp;lt;= datetime(01/01/1935 00:00:00) and INSTALLATIONDATEUPPERLIMIT &amp;gt;= datetime(01/01/2035 00:00:00)"&lt;BR /&gt;#ID_where_Clause = "(INSTALLATIONDATELOWERLIMIT &amp;lt;= {} and INSTALLATIONDATEUPPERLIMIT &amp;gt;= {})".format(INSTALLATIONDATE)&lt;BR /&gt;#Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ID_Out_fields, ID_where_Clause)&lt;BR /&gt;#for row in Table_Pipe_Cursor:&lt;BR /&gt;#lst.append(row[2])&lt;BR /&gt;#ID_Risk_Score = row[2]&lt;BR /&gt;#print (ID_Risk_Score)"""&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#Final_Risk_Score = (Material_Risk_Score + OP_Risk_Score + ML_Risk_Score + ID_Risk_Score)/4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;#Pipe_Risk_Score(Material , OPERATINGPRESSURE , MEASUREDLENGTH , INSTALLATIONDATE) # Showing me Name error using this line without quotes&lt;BR /&gt;Pipe_Risk_Score("Material" , "OPERATINGPRESSURE" , "MEASUREDLENGTH" , "INSTALLATIONDATE")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 03:44:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087357#M61997</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-10T03:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087360#M61998</link>
      <description>&lt;P&gt;But I'm interested in a overall risk score of individual value. I want the average as a return function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please have a look at my complete code:&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from datetime import datetime&lt;BR /&gt;arcpy.env.workspace = "D:\Pipe\map.gdb"&lt;BR /&gt;featureClass_1 = "P_Pipes"&lt;BR /&gt;Table_Pipe = "Pipe_Risk"&lt;BR /&gt;fieldNames_1 = [ "Material" , "OPERATINGPRESSURE" , "MEASUREDLENGTH" , "INSTALLATIONDATE", "Risk_Score"]&lt;BR /&gt;fieldNames = ["Material" , "OPERATINGPRESSURE" , "MEASUREDLENGTHLOWERLIMIT" ,"MEASUREDLENGTHUPPERLIMIT" , "INSTALLATIONDATELOWERLIMIT" , "INSTALLATIONDATEUPPERLIMIT" , "OVERALLRISKSCORE"]&lt;/P&gt;&lt;P&gt;lst=[]&lt;/P&gt;&lt;P&gt;def Pipe_Risk_Score(Material, OPERATINGPRESSURE, MEASUREDLENGTH, INSTALLATIONDATE):&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Case: Material&lt;/P&gt;&lt;P&gt;#Material_Out_fields = ["Material" , "OVERALLRISKSCORE"]&lt;BR /&gt;&lt;BR /&gt;Material_where_Clause = "Material = " + Material&lt;BR /&gt;Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ["Material" , "OVERALLRISKSCORE"],Material_where_Clause)&lt;BR /&gt;for row in Table_Pipe_Cursor:&lt;BR /&gt;# lst.append(row[1])&lt;BR /&gt;Material_Risk_Score = row[1]&lt;BR /&gt;print Material_Risk_Score&lt;/P&gt;&lt;P&gt;# Case: Operating Pressure&lt;/P&gt;&lt;P&gt;OP_Out_fields = ["OPERATINGPRESSURE" , "OVERALLRISKSCORE"]&lt;BR /&gt;OP_where_Clause = "OPERATINGPRESSURE = " + OPERATINGPRESSURE&lt;BR /&gt;Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, OP_Out_fields, OP_where_Clause)&lt;/P&gt;&lt;P&gt;for row in Table_Pipe_Cursor:&lt;BR /&gt;lst.append(row[1])&lt;BR /&gt;OPERATINGPRESSURE_Risk_Score = row[1]&lt;BR /&gt;print (OPERATINGPRESSURE_Risk_Score)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Case: ML&lt;/P&gt;&lt;P&gt;ML_Out_fields = ["MEASUREDLENGTHLOWERLIMIT" ,"MEASUREDLENGTHUPPERLIMIT" , "OVERALLRISKSCORE"]&lt;BR /&gt;ML_where_Clause = "MEASUREDLENGTHLOWERLIMIT &amp;lt;= " + MEASUREDLENGTH + " and MEASUREDLENGTHUPPERLIMIT &amp;gt;= " + MEASUREDLENGTH #.format(MEASUREDLENGTH)&lt;BR /&gt;print ML_where_Clause&lt;BR /&gt;#Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ML_Out_fields, ML_where_Clause)&lt;BR /&gt;#ML_where_Clause = "MEASUREDLENGTHLOWERLIMIT &amp;lt;= " + MEASUREDLENGTH + " and MEASUREDLENGTHUPPERLIMIT &amp;gt;= " + MEASUREDLENGTH.format(MEASUREDLENGTH, MEASUREDLENGTH)&lt;BR /&gt;# print(ML_where_Clause)&lt;BR /&gt;#ML_where_Clause = "CAST(MEASUREDLENGTHUPPERLIMIT AS INTEGER &amp;lt;= "MEASUREDLENGTHUPPERLIMIT" and "MEASUREDLENGTHUPPERLIMIT" &amp;gt;= "MEASUREDLENGTHLOWERLIMITTable_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ML_Out_fields, ML_where_Clause)&lt;/P&gt;&lt;P&gt;"""for row in Table_Pipe_Cursor:&lt;BR /&gt;lst.append(row[2])&lt;BR /&gt;MEASUREDLENGTH_Risk_Score = row[2]&lt;BR /&gt;print MEASUREDLENGTH_Risk_Score"""&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Case: ID&lt;/P&gt;&lt;P&gt;INSTALLATIONDATE = datetime.strptime("1935-01-01 " ,"%Y-%m-%d") #"01/01/2035 00:00:00")&lt;BR /&gt;ID_Out_fields = ["INSTALLATIONDATELOWERLIMIT" , "INSTALLATIONDATEUPPERLIMIT" , "OVERALLRISKSCORE"]&lt;BR /&gt;ID_where_Clause = "INSTALLATIONDATELOWERLIMIT &amp;lt;= datetime(1935-01-01 ) and INSTALLATIONDATEUPPERLIMIT &amp;gt;= datetime(2035-01-01 )"&lt;BR /&gt;#ID_where_Clause = "(INSTALLATIONDATELOWERLIMIT &amp;lt;= {} and INSTALLATIONDATEUPPERLIMIT &amp;gt;= {})".format(INSTALLATIONDATE)&lt;BR /&gt;Table_Pipe_Cursor = arcpy.da.SearchCursor(Table_Pipe, ID_Out_fields, ID_where_Clause)&lt;BR /&gt;for row in Table_Pipe_Cursor:&lt;BR /&gt;#lst.append(row[2])&lt;BR /&gt;ID_Risk_Score = row[2]&lt;BR /&gt;print (ID_Risk_Score)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#Final_Risk_Score = (Material_Risk_Score + OP_Risk_Score + ML_Risk_Score + ID_Risk_Score)/4&lt;/P&gt;&lt;P&gt;#Pipe_Risk_Score(Material , OPERATINGPRESSURE , MEASUREDLENGTH , INSTALLATIONDATE) # Showing me Name error using this line without quotes&lt;BR /&gt;Pipe_Risk_Score("Material" , "OPERATINGPRESSURE" , "MEASUREDLENGTH" , "INSTALLATIONDATE")&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 04:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087360#M61998</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-10T04:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087640#M62016</link>
      <description>&lt;P&gt;This is getting beyond the scope of the original question.&amp;nbsp; If the field values you are tying to use in the queries are coming from the same table as what you are using to get the information from, I think you could simplify this script into a single cursor and drop the multiple sql queries on each field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unclear if you are trying to average each features value across the fields, or average the field across all features.&amp;nbsp; This is not tested but should do both and get you started- you can add/ delete what you need when you debug it against the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.env.workspace = "D:\Pipe\map.gdb"
featureClass_1 = "P_Pipes"
Table_Pipe = "Pipe_Risk"

# Lists for holding values from the cursor
material_overall = []
opPressureOverall = []
measuredlengthOverall = []
riskscoreOverall = []

with arcpy.da.SearchCursor(Table_Pipe, ["Material", "OPERATINGPRESSURE", "MEASUREDLENGTH",
                                        "INSTALLATIONDATELOWERLIMIT", "INSTALLATIONDATEUPPERLIMIT",
                                        "OVERALLRISKSCORE"]) as sCur:
    for row in sCur:
        Material_Risk_Score = row[0]
        # filter Nulls
        if Material_Risk_Score is not None:
            material_overall.append(Material_Risk_Score)

        OPERATINGPRESSURE_Risk_Score = row[1]
        if OPERATINGPRESSURE_Risk_Score is not None:
            measuredlengthOverall.append(OPERATINGPRESSURE_Risk_Score)

        MEASUREDLENGTH_Risk_Score = row[2]
        if MEASUREDLENGTH_Risk_Score is not None:
            measuredlengthOverall.append(MEASUREDLENGTH_Risk_Score)
        
        # This can probably be just a Null check instead of dates becuase this will always be true for the values shown in the table unless its Null.
        # if row[3] &amp;lt;= '2035-01-01' and row[4] &amp;gt;= '1935-01-01':
        if row[3] is not None and row[4] is not None:
            ID_Risk_Score = row[5]
            riskscoreOverall.append(ID_Risk_Score)
            # There are no values in the other fields if the dates are filled in so not sure if this is correct:
            print "Feature risk average: {}".format(
                Material_Risk_Score + OPERATINGPRESSURE_Risk_Score + MEASUREDLENGTH_Risk_Score + ID_Risk_Score / 4)

        else:
            # average the three fields for each feature leaving the installation out because there are no date values if these
            # fields have values.
            print "Feature risk average: {}".format(
                Material_Risk_Score + OPERATINGPRESSURE_Risk_Score + MEASUREDLENGTH_Risk_Score / 3)


# if you want average of the fields across all features.
print 'material_overall average = {}'.format(sum(material_overall) / len(material_overall))
print 'Operating Pressure average = {}'.format(sum(measuredlengthOverall) / len(measuredlengthOverall))
print 'Measured Length average = {}'.format(sum(measuredlengthOverall) / len(measuredlengthOverall))
print 'Risk Score average = {}'.format(sum(riskscoreOverall) / len(riskscoreOverall))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 19:36:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087640#M62016</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-10T19:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087654#M62017</link>
      <description>&lt;P&gt;Sir, What i have to actually do is taking the "overall risk score" from the lookup table for each value in the feature class and then after accessing the "Overall risk score" for each value in my lookup table. I'm trying to update it in the main feature class( I have added a new field "Risk_Score" here)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, what i wanna do is reading the value from the lookup table &amp;amp; update the average of Risk score in my original feature class attributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Material = 3&lt;/P&gt;&lt;P&gt;Operating Pressure = 40&lt;/P&gt;&lt;P&gt;Measured Length = 52.5&lt;/P&gt;&lt;P&gt;Installation Date = 2015-4-01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say overall risk score for Material (3) = 0.3&lt;/P&gt;&lt;P&gt;Say overall risk score for Operating pressure(40) = 0.1&lt;/P&gt;&lt;P&gt;Say overall risk score for Measured Length(52.5) = 1.2&lt;/P&gt;&lt;P&gt;Say overall risk score for Installation Date(2015-4-01) = 1&lt;/P&gt;&lt;P&gt;#And most importantly, I wanna read the "Overall Risk Score" for each parameters not their value, I just want for Operating Pressure =120, what'll be the overall risk score from the lookup table.&lt;/P&gt;&lt;P&gt;Pipe_Risk_Score = (Overall Risk Score (Material) +&amp;nbsp;Overall Risk Score(Operating Pressure)+&amp;nbsp;Overall Risk Score(Measured Length)+&amp;nbsp;Overall Risk Score(Installation Date) ) /4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's why I have defined the function, so that i can pass the return average value while updating the field value.&lt;/P&gt;&lt;P&gt;# below is the psuedo code, what i wanna do after the search cursor.&lt;/P&gt;&lt;P&gt;PipeCursor = arcpy.da.UpdateCursor(GDBPath,PipeFCName)&lt;BR /&gt;for row in PipeCursor&lt;/P&gt;&lt;P&gt;Material = row[0] // Cast Iron&lt;BR /&gt;OperatingPressure = row[1] // 120&lt;BR /&gt;MeasuredLength = row[3] // 100&lt;BR /&gt;InstallationDate = row[4] // 1-Jan-1990&lt;/P&gt;&lt;P&gt;PipeRiskScore = Pipe_Risk_Score(Material,OperatingPressure,MeasuredLength,InstallationDate)&lt;/P&gt;&lt;P&gt;row.set_value("OverallRiskScore",PipeRiskScore)&lt;/P&gt;&lt;P&gt;Then I have to update it into my feature class by taking all the parameters into consideration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sir, do you understand now, what i'm trying to do? Now please suggest&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 20:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087654#M62017</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-10T20:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087671#M62019</link>
      <description>&lt;P&gt;Ok, using the cursor example I posted earlier:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.env.workspace = "D:\Pipe\map.gdb"
featureClass_1 = "P_Pipes"
Table_Pipe = "Pipe_Risk"
fieldNames_1 = ["Material", "OPERATINGPRESSURE", "MEASUREDLENGTH", "INSTALLATIONDATE", "Risk_Score"]
fieldNames = ["Material", "OPERATINGPRESSURE", "MEASUREDLENGTHLOWERLIMIT", "MEASUREDLENGTHUPPERLIMIT",
              "INSTALLATIONDATELOWERLIMIT", "INSTALLATIONDATEUPPERLIMIT", "OVERALLRISKSCORE"]


def Pipe_Risk_Score(Material, OPERATINGPRESSURE, MEASUREDLENGTH, INSTALLATIONDATE):
    lst = []
    # Case: Material
    Material_where_Clause = "Material = " + Material
    with arcpy.da.SearchCursor(Table_Pipe, ["Material", "OVERALLRISKSCORE"], Material_where_Clause) as sCur:
        for row in sCur:
            lst.append(row[1])
            Material_Risk_Score = row[1]
            print Material_Risk_Score

    # Case: Operating Pressure
    OP_Out_fields = ["OPERATINGPRESSURE", "OVERALLRISKSCORE"]
    OP_where_Clause = "OPERATINGPRESSURE = " + OPERATINGPRESSURE
    with arcpy.da.SearchCursor(Table_Pipe, OP_Out_fields, OP_where_Clause) as sCur:
        for row in sCur:
            lst.append(row[1])
            OPERATINGPRESSURE_Risk_Score = row[1]
            print OPERATINGPRESSURE_Risk_Score

    # Case: ML
    ML_Out_fields = ["MEASUREDLENGTHLOWERLIMIT", "MEASUREDLENGTHUPPERLIMIT", "OVERALLRISKSCORE"]
    ML_where_Clause = "MEASUREDLENGTHLOWERLIMIT &amp;lt;= " + MEASUREDLENGTH + " and MEASUREDLENGTHUPPERLIMIT &amp;gt;= " + MEASUREDLENGTH
    print ML_where_Clause
    with arcpy.da.SearchCursor(Table_Pipe, ML_Out_fields, ML_where_Clause) as sCur:
        for row in sCur:
            lst.append(row[2])
            MEASUREDLENGTH_Risk_Score = row[2]
            print MEASUREDLENGTH_Risk_Score

    # Case: ID
    ID_Out_fields = ["INSTALLATIONDATELOWERLIMIT", "INSTALLATIONDATEUPPERLIMIT", "OVERALLRISKSCORE"]
    ID_where_Clause = "INSTALLATIONDATELOWERLIMIT &amp;lt;= {0} and INSTALLATIONDATEUPPERLIMIT &amp;gt;= {0}".format(INSTALLATIONDATE)
    with arcpy.da.SearchCursor(Table_Pipe, ID_Out_fields, ID_where_Clause) as sCur:
        for row in sCur:
            lst.append(row[2])
            ID_Risk_Score = row[2]
            print ID_Risk_Score

    return sum(lst) / len(lst)


with arcpy.da.UpdateCursor(PipeFCName, ["Material", "OPERATINGPRESSURE", "MEASUREDLENGTH", "INSTALLATIONDATE", "Risk_Score"]) as uCur:
    for row in uCur:
        Material = row[0]
        OPERATINGPRESSURE = row[1]
        MEASUREDLENGTH = row[2]
        INSTALLATIONDATE = row[3]

        row[4] = Pipe_Risk_Score(Material, OPERATINGPRESSURE, MEASUREDLENGTH, INSTALLATIONDATE)
        uCur.UpdateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 21:13:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087671#M62019</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-10T21:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087806#M62023</link>
      <description>&lt;P&gt;I would like to thanks for your continuous effort on my code. Sir, I'm having no problem with "Material &amp;amp; Operating Pressure", &lt;STRONG&gt;but unable to print my 'Installation Date &amp;amp; Measured Length' "Overall Risk score".&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The error is in the for loop of Measured Length. Below is the error which i'm getting:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;BR /&gt;File "D:\Arcpy\Material.py", line 51, in &amp;lt;module&amp;gt;&lt;BR /&gt;Pipe_Risk_Score("Material", "OPERATINGPRESSURE", "MEASUREDLENGTH", "INSTALLATIONDATE")&lt;BR /&gt;File "D:\Arcpy\Material.py", line 35, in Pipe_Risk_Score&lt;BR /&gt;for row in sCur:&lt;BR /&gt;RuntimeError: An expected Field was not found or could not be retrieved properly. [Pipe_Risk]&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We're almost done with the code, please tell me how to rectify the same error.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 05:52:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087806#M62023</guid>
      <dc:creator>broy06</dc:creator>
      <dc:date>2021-08-11T05:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Error in my where clause using cursor in arcpy.</title>
      <link>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087828#M62024</link>
      <description>&lt;P&gt;"&lt;STRONG&gt;An expected Field was not found or could not be retrieved properly. [Pipe_Risk]&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;Your where clause is not getting the value of MEASUREDLENGTH and is getting 'MEASUREDLENGTH' as a string for that feature.&amp;nbsp; Does your table have 'MEASUREDLENGTH' mixed in with the values?&lt;/P&gt;&lt;P&gt;I'd try the where cause formatted like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ML_where_Clause = "MEASUREDLENGTHLOWERLIMIT &amp;lt;= {0} and MEASUREDLENGTHUPPERLIMIT &amp;gt;= {0}".format(MEASUREDLENGTH)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you see the variable name printed in the where clause (like in the screenshot you shared) and not the expected 3, 4, 1 value, you need to debug why that is happening and write code to handle it.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 09:21:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-error-in-my-where-clause-using-cursor-in/m-p/1087828#M62024</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-11T09:21:02Z</dc:date>
    </item>
  </channel>
</rss>

