<?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: How to select on an Oracle Database Sequence value in arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3959#M343</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you execute the SQL in SQL Developer, Toad or whatever database tool/UI, what is the result?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I copied your sql "SELECT ID_SEQ.CURRVAL FROM DUAL" into a SQL Developer query window and ran it and it returned the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"ORA-02289: squence does not exist"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cause: the sequence does not exist or the user does not have the required privilege to perform this operation&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Action: make sure the sequence name is correct, and that you have the right to perform the desired operatoin on this sequence.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Vendor code 2289Error at Line: 1 Column 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can run the statement on your SQL developer without error, then you may want to implement cx_Oracle Python library to execute your sql commands.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Nov 2013 11:51:00 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2013-11-20T11:51:00Z</dc:date>
    <item>
      <title>How to select on an Oracle Database Sequence value in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3958#M342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to be able to get an Oracle Database Sequence value (either CURRVAL or NEXTVAL) using an arcpy sql query. I used a &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;generic sql execute function as opposed to the SelectCursor function but cannot seem to be able to get the sequence value &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;returned fromthe sql call into the python script. The examples I have seen can execute the call but the value I get returned is a &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;float, I am guessing a representation of a boolean which represents whether the sql successfully executed or not. The code we&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;have is something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; sql = "SELECT ID_SEQ.CURRVAL FROM DUAL"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; connSQl = arcpy.ArcSDESQLExecute("\Database Connections\Geodatabase.sde")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; sqlresults = connSQL.execute(sql)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; ## sqlResults is non-iterable so I cannot for loop through a list [as rows to qualify]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; The sequence value is a positive integer yet I get some value 2e-10 back&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Can anyone show me what I am doing wrong here or if there is another function I should be using to talk to a a non-table &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;database object like a sequence. There must be since SDE uses so many of them for IDs. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. If not, the same question for a PL/SQL stored procedure call, getting a return value out.&amp;nbsp; Our sequences have PL/SQL function &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;accessors so if there is way to get these values this way that would be fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We would prefer to use arcpy and avoid the other oracle based sql call modules simply to keep our connection credentials &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;encapsulated in our sde objects. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you know of some examples out there, throw me bone since my searches come up[ with only table examples.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;("table scraps" if you will...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks much,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-James Fox&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Nov 2013 02:00:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3958#M342</guid>
      <dc:creator>JamesFox1</dc:creator>
      <dc:date>2013-11-20T02:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to select on an Oracle Database Sequence value in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3959#M343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you execute the SQL in SQL Developer, Toad or whatever database tool/UI, what is the result?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I copied your sql "SELECT ID_SEQ.CURRVAL FROM DUAL" into a SQL Developer query window and ran it and it returned the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"ORA-02289: squence does not exist"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cause: the sequence does not exist or the user does not have the required privilege to perform this operation&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Action: make sure the sequence name is correct, and that you have the right to perform the desired operatoin on this sequence.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Vendor code 2289Error at Line: 1 Column 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can run the statement on your SQL developer without error, then you may want to implement cx_Oracle Python library to execute your sql commands.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Nov 2013 11:51:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3959#M343</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-11-20T11:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to select on an Oracle Database Sequence value in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3960#M344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, the sequence does exists and I get an integer value back when I run the SQL in SQL*PLUS. The second part of the question deals calling a PL/SQL function from arcpy. If so, we can go that route. I do not get an ORA error from the code but the return value is giberish and unusable, as clearly I did not get the sequence value back from the call.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the meantime, I will look into cx_oracle but like I said I am useasy about hardcoing login credentials into code like the examples I have seen. That is why I would prefer to do this using arcpy because the credentials are obtained from the users sde files which are &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;used connect to the database when they pick their input feature classes in the GP tool interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Nov 2013 15:28:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3960#M344</guid>
      <dc:creator>JamesFox1</dc:creator>
      <dc:date>2013-11-20T15:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to select on an Oracle Database Sequence value in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3961#M345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;James,&lt;BR /&gt;&lt;BR /&gt;Yes, the sequence does exists and I get an integer value back when I run the SQL in SQL*PLUS. The second part of the question deals calling a PL/SQL function from arcpy. If so, we can go that route. I do not get an ORA error from the code but the return value is giberish and unusable, as clearly I did not get the sequence value back from the call.&lt;BR /&gt;&lt;BR /&gt;In the meantime, I will look into cx_oracle but like I said I am useasy about hardcoing login credentials into code like the examples I have seen. That is why I would prefer to do this using arcpy because the credentials are obtained from the users sde files which are &lt;BR /&gt;used connect to the database when they pick their input feature classes in the GP tool interface.&lt;BR /&gt;&lt;BR /&gt;-Jim&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm fairly new to Oracle, but lots of RDBMS development work on other systems (SQL Server), so the sequence thing is new for me.&amp;nbsp; But that doesn't seem to be the problem and I suspect it has to do with ArcSDESQLExecute inability to determine just what the heck is going on. Here's hoping you can find a way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use a DSN or TNS name for the cx_Oracle connection parameters and you should have no problem interfacing with your Stored Procedures.&amp;nbsp; We use the cx_Oracle library and it works very well for us (and we are in a Citrix envrionment too).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Nov 2013 16:48:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3961#M345</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-11-20T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to select on an Oracle Database Sequence value in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3962#M346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//002z00000021000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//002z00000021000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"The object will return a list of lists in the case where the statement returns rows from a table; for statements that do not return rows, it will return an indication of the success or failure of the statement (True for success, None for failure)."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I suspect that since you are not returning rows, you are evaluating something else as a result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: try this and see if it produces your expected value...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

sqlresults = connSQL.execute(sql)
for result in sqlresults:
&amp;nbsp;&amp;nbsp; print result 

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:09:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-select-on-an-oracle-database-sequence-value/m-p/3962#M346</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-10T20:09:57Z</dc:date>
    </item>
  </channel>
</rss>

