<?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: Oracle Table Object in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648503#M50483</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about passing an array variable (&lt;A href="http://cx-oracle.readthedocs.org/en/latest/cursor.html#Cursor.arrayvar"&gt;Cursor.arrayvar&lt;/A&gt;) instead of a cursor?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Mar 2015 21:28:49 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2015-03-26T21:28:49Z</dc:date>
    <item>
      <title>Oracle Table Object in Python</title>
      <link>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648502#M50482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to use Python to call a procedure in another Oracle database (using &lt;A href="http://cx-oracle.readthedocs.org/en/latest/index.html" rel="nofollow noopener noreferrer" target="_blank"&gt;cx_Oracle&lt;/A&gt;) that requires an input parameter of a table object. The table object needs to be comprised of some records from our Oracle SDE (a fairly simple select statement). Using Python, how do I create an Oracle table object to send it to the stored procedure?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something kind of like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;oracle_sde = u'UserNameHere/PasswordHere@DatabaseNameHere'
oracle_otherdb = u'UserNameHere/PasswordHere@DatabaseNameHere'
sql = "SELECT * FROM TABLE_NAME"
sde_cnxn = cx_Oracle.connect(oracle_sde)
sde_cursor = sde_cnxn.cursor()
sde_cursor.execute(sql)
otherdb_cnxn = cx_Oracle.connect(oracle_otherdb)
otherdb_cursor = otherdb_cnxn.cursor()
otherdb_cursor.callproc("MyProcedure", sde_cursor.fetchall())&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it's not really a GIS question, but I figured you guys would be up for the challenge!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:29:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648502#M50482</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-12T03:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle Table Object in Python</title>
      <link>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648503#M50483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about passing an array variable (&lt;A href="http://cx-oracle.readthedocs.org/en/latest/cursor.html#Cursor.arrayvar"&gt;Cursor.arrayvar&lt;/A&gt;) instead of a cursor?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 21:28:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648503#M50483</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-26T21:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle Table Object in Python</title>
      <link>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648504#M50484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I believe I do need to &lt;A href="http://www.oracle.com/technetwork/articles/prez-stored-proc-084100.html" rel="nofollow noopener noreferrer" target="_blank"&gt;create an array&lt;/A&gt;. I'd like to provide some more information about the procedure I'm calling. It has an input of a table type and an output of a table type. Both in and out tables are defined with a custom &lt;SPAN style="font-family: 'courier new', courier;"&gt;RECORD&lt;/SPAN&gt; datatype.&lt;/P&gt;&lt;P&gt;Here's how the input table is defined:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;TYPE meter_info_tab_type IS TABLE OF meter_info_rec_type
INDEX BY BINARY_INTEGER;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a sample of what the input table's record type looks like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;TYPE meter_info_rec_type IS RECORD
(
&amp;nbsp;&amp;nbsp;&amp;nbsp; c_esb_guid&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; VARCHAR2(50),
&amp;nbsp;&amp;nbsp;&amp;nbsp; c_newserialnum&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VARCHAR2(10),
&amp;nbsp;&amp;nbsp;&amp;nbsp; c_remoteid&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; VARCHAR2(15),
&amp;nbsp;&amp;nbsp;&amp;nbsp; d_install&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; DATE,
&amp;nbsp;&amp;nbsp;&amp;nbsp; c_remotetype&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VARCHAR2(2),
&amp;nbsp;&amp;nbsp;&amp;nbsp; c_recordtype&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VARCHAR2(1),
&amp;nbsp;&amp;nbsp;&amp;nbsp; l_processed&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NUMBER,
)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's how the input and output tables are used in the procedure:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;PROCEDURE InsertMeterInfo
(
&amp;nbsp;&amp;nbsp; p_error_data&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OUT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; error_tab_type,
&amp;nbsp;&amp;nbsp; p_meter_info_data&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; meter_info_tab_type
)
IS
... rest of procedure code...&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the cx_oracle &lt;SPAN style="font-family: 'courier new', courier;"&gt;arrayvar()&lt;/SPAN&gt; examples use &lt;SPAN style="font-family: 'courier new', courier;"&gt;VARCHAR2&lt;/SPAN&gt; or &lt;SPAN style="font-family: 'courier new', courier;"&gt;NUMBER&lt;/SPAN&gt; datatypes. How do I define an arrayvar with a &lt;SPAN style="font-family: 'courier new', courier;"&gt;RECORD&lt;/SPAN&gt; datatype so I can put in a list of lists or tuples for the rows? &lt;A href="http://dbaportal.eu/sidekicks/sidekick-cx_oracle-code-paterns/#part3.4" rel="nofollow noopener noreferrer" target="_blank"&gt;This page&lt;/A&gt; looked to have some promising information, but I'm still having trouble.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:29:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648504#M50484</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-12T03:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle Table Object in Python</title>
      <link>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648505#M50485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your OP you are just issuing an SQL SELECT statement against the table.&amp;nbsp; That will work just fine but that is a separate thing from calling PL/SQL packages with cx_Oracle --- from the link in your second post, read the section titled Part 3.4 – PL/SQL to see how he is doing that.&amp;nbsp; There is also example of setting up a refcursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think in any case you will have to transform from the cx_Oracle cursor into something usable for (I'm not sure what you need to do with the&amp;nbsp; results).&amp;nbsp; You could just populate a list and numpy array to go between spatial and non-spatial sets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 13:36:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648505#M50485</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2015-03-30T13:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle Table Object in Python</title>
      <link>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648506#M50486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the confusion with the first post. I was just trying to get my thoughts out into some psuedo code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, the procedure I'm calling does not use a refcursor; it has to be a table object of record datatype.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 15:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648506#M50486</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-03-30T15:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle Table Object in Python</title>
      <link>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648507#M50487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply's guys. I think the answer is that this can't be done. I've come across a few sources that claim it is not possible to send a PL/SQL record type table object through cx_Oracle.&lt;/P&gt;&lt;P&gt;&lt;A href="http://comments.gmane.org/gmane.comp.python.db.cx-oracle/1256" title="http://comments.gmane.org/gmane.comp.python.db.cx-oracle/1256"&gt;Discussion of the cx_Oracle Python interface to Oracle ()&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 15:38:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/oracle-table-object-in-python/m-p/648507#M50487</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-03-30T15:38:06Z</dc:date>
    </item>
  </channel>
</rss>

