<?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: feature class and SQL in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701535#M54353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, Jake&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much for your help.&amp;nbsp; I have ArcGIS 9.3, does this code work?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Mar 2012 19:55:00 GMT</pubDate>
    <dc:creator>JinMa</dc:creator>
    <dc:date>2012-03-23T19:55:00Z</dc:date>
    <item>
      <title>feature class and SQL</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701533#M54351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to use search cursor to iterate a feature class, get 'code' field from each row, use 'code' to query an oracle table, if returns multiple records associated with this code, then remove this code from the feature class, if returns single record associated with this code then keep.&amp;nbsp; Any help or hint will be greatly appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 13:04:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701533#M54351</guid>
      <dc:creator>JinMa</dc:creator>
      <dc:date>2012-03-21T13:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: feature class and SQL</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701534#M54352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was able to do this using the &lt;/SPAN&gt;&lt;A href="http://cx-oracle.sourceforge.net/" rel="nofollow noopener noreferrer" target="_blank"&gt;cx_Oracle&lt;/A&gt;&lt;SPAN&gt; module.&amp;nbsp; Here is an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, cx_Oracle
from arcpy import env
env.workspace = r"C:\TEMP\Python\Test.gdb"
env.overwriteOutput = 1

fc = "Hospitals"

list = []

# append all CODE values from feature class to list
rows = arcpy.SearchCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list.append(row.getValue("FAC_TYPE"))

# create a connection to Oracle instance&amp;nbsp;&amp;nbsp;&amp;nbsp; 
connstr='vector/vector@orcl'
conn = cx_Oracle.connect(connstr)
curs = conn.cursor()

oracleList = []

# query Oracle table using items from list and append to new list
for item in list:
&amp;nbsp;&amp;nbsp;&amp;nbsp; curs.execute('select FAC_TYPE FROM Hospital_Info where FAC_TYPE = ' + str(item))
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oracleList.append(row[0])

# Find items that have duplicates and delete from feature class
for item in set(oracleList):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oracleList.count(item) &amp;gt; 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc, "Hospital_Lyr", "FAC_TYPE = " + str(item))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DeleteRows_management("Hospital_Lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Successfully deleted rows"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
conn.close()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:30:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701534#M54352</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T05:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: feature class and SQL</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701535#M54353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, Jake&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much for your help.&amp;nbsp; I have ArcGIS 9.3, does this code work?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 19:55:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701535#M54353</guid>
      <dc:creator>JinMa</dc:creator>
      <dc:date>2012-03-23T19:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: feature class and SQL</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701536#M54354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is actually for ArcGIS 10.&amp;nbsp; You will need to replace 'arcpy' with 'gp' to have this work with 9.3.&amp;nbsp; Also, you will need to make a few changes to the 'SearchCursor'.&amp;nbsp; Here is a &lt;/SPAN&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=SearchCursor_method"&gt;link&lt;/A&gt;&lt;SPAN&gt; that discusses how to do this for 9.3.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2012 09:51:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701536#M54354</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-03-26T09:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: feature class and SQL</title>
      <link>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701537#M54355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Jin,&lt;BR /&gt;&lt;BR /&gt;This is actually for ArcGIS 10.&amp;nbsp; You will need to replace 'arcpy' with 'gp' to have this work with 9.3.&amp;nbsp; Also, you will need to make a few changes to the 'SearchCursor'.&amp;nbsp; Here is a &lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=SearchCursor_method"&gt;link&lt;/A&gt; that discusses how to do this for 9.3.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi, Jake, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me tell you more clear what I have and what I need to do: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a FGDB feature class derived from intersect_analysis, it contains almost million records, and it has many duplicated records associated with field 'code'.&amp;nbsp; I need to compare records with oracle, if oracle returns only one record associated with 'code', then keep or append to new feature class.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried hard, it's so slow, not success...I have Arc9.3. Thanks so much.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Mar 2012 04:15:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-class-and-sql/m-p/701537#M54355</guid>
      <dc:creator>JinMa</dc:creator>
      <dc:date>2012-03-27T04:15:55Z</dc:date>
    </item>
  </channel>
</rss>

