<?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: Update table using select from the same table + st functions in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/update-table-using-select-from-the-same-table-st/m-p/417364#M23811</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've been reviewing my posts on the forums and came across this one, so I thought I could share my solution with the rest of you... someone might hopefully find it helpful one day:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;well, it never worked with ST_intersects, so I've switched to St_Contains and that one seemed to work. Then I've used the EXISTS keyword, which has later proved to be a crucial part of the statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
UPDATE stat.AP x SET x.is_alloc = 1, x.SO_ID = 555 WHERE ((x.ZSJ_ID = 353) AND EXISTS(SELECT y.objectid FROM stat.SO y WHERE sde.ST_Contains(y.shape, x.shape) = 1))
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this might be a slightly different to what I initially wrote in my first post, but the idea is there&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:52:36 GMT</pubDate>
    <dc:creator>MichalGasparovic</dc:creator>
    <dc:date>2021-12-11T18:52:36Z</dc:date>
    <item>
      <title>Update table using select from the same table + st functions</title>
      <link>https://community.esri.com/t5/data-management-questions/update-table-using-select-from-the-same-table-st/m-p/417363#M23810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcSDE 9.3.1 SP1, ORACLE 11g&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I seem to be struggling a bit with the proper sql syntax for the following task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;table A = polygons of administrative boundaries&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;table B = address points&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to update table B with the administrative area code (table A) of the area that contains the address point... also, it might happen, that one address point might fall into two (or even more) administrative areas, for me it's fine to take the first one the select command encounters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;something like this doesn't work : &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
UPDATE ap x SET x.area_id = (SELECT a.area_id FROM zsj_za a, ap b WHERE (sde.st_intersects(a.shape, b.shape) = 1 AND abody.objectid = x.objectid AND rownum = 1)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;returns the following error message : &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Error starting at line 1 in command:&lt;BR /&gt;UPDATE ab x SET x.zsj_id = (SELECT zsj.zsj_id FROM zsj_za zsj, ab abody WHERE (sde.st_intersects(zsj.shape, abody.shape) = 1 AND zsj.okres IN ('Martin') AND abody.objectid = x.objectid))&lt;BR /&gt;Error report:&lt;BR /&gt;SQL Error: ORA-29902: error in executing ODCIIndexStart() routine&lt;BR /&gt;ORA-06521: PL/SQL: Error mapping function&lt;BR /&gt;ORA-06522: Unable to load symbol from DLL&lt;BR /&gt;ORA-06512: at "SDE.ST_GEOMETRY_SHAPELIB_PKG", line 943&lt;BR /&gt;ORA-06512: at "SDE.SPX_UTIL", line 2623&lt;BR /&gt;ORA-06512: at "SDE.SPX_UTIL", line 2842&lt;BR /&gt;ORA-06512: at "SDE.ST_DOMAIN_METHODS", line 282&lt;BR /&gt;29902. 00000 -&amp;nbsp; "error in executing ODCIIndexStart() routine"&lt;BR /&gt;*Cause:&amp;nbsp;&amp;nbsp;&amp;nbsp; The execution of ODCIIndexStart routine caused an error.&lt;BR /&gt;*Action:&amp;nbsp;&amp;nbsp; Examine the error messages produced by the indextype code and&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; take appropriate action.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;St_functions are running properly if I do pretty simple queries. I reckon it's the problem of the syntax &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; obviously, I'm missing the concept of updating the table using the select command where the same table appears.... any ideas are more than welcome.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you in advance for all your help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:52:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-table-using-select-from-the-same-table-st/m-p/417363#M23810</guid>
      <dc:creator>MichalGasparovic</dc:creator>
      <dc:date>2021-12-11T18:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Update table using select from the same table + st functions</title>
      <link>https://community.esri.com/t5/data-management-questions/update-table-using-select-from-the-same-table-st/m-p/417364#M23811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've been reviewing my posts on the forums and came across this one, so I thought I could share my solution with the rest of you... someone might hopefully find it helpful one day:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;well, it never worked with ST_intersects, so I've switched to St_Contains and that one seemed to work. Then I've used the EXISTS keyword, which has later proved to be a crucial part of the statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
UPDATE stat.AP x SET x.is_alloc = 1, x.SO_ID = 555 WHERE ((x.ZSJ_ID = 353) AND EXISTS(SELECT y.objectid FROM stat.SO y WHERE sde.ST_Contains(y.shape, x.shape) = 1))
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this might be a slightly different to what I initially wrote in my first post, but the idea is there&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-table-using-select-from-the-same-table-st/m-p/417364#M23811</guid>
      <dc:creator>MichalGasparovic</dc:creator>
      <dc:date>2021-12-11T18:52:36Z</dc:date>
    </item>
  </channel>
</rss>

