<?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: cx_Oracle error &amp;quot;SQL Statement not properly ended in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1169802#M64459</link>
    <description>&lt;P&gt;Does the .execute() string need to be terminated with a semicolon?&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2022 18:26:03 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2022-05-02T18:26:03Z</dc:date>
    <item>
      <title>cx_Oracle error "SQL Statement not properly ended</title>
      <link>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1169584#M64449</link>
      <description>&lt;P&gt;Hello all, I am currently doing an assignment that links python to SQL Developer, and I keep getting errors that my statements for "custCursor.execute" and "delivCursor.execute" are not properly ended, but I cannot figure out why. any help would be greatly appreciated, and the code is posted below. the first query "custIDCursor.execute" works great, and will even display everything that I need it to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Get Parameter for the CustIDQuery&lt;BR /&gt;prompt1 = '&amp;gt;'&lt;BR /&gt;print(f"Enter the Customer's Last Name: ")&lt;BR /&gt;lnameValue = input(prompt1)&lt;/P&gt;&lt;P&gt;# Set up cursor and retrieve data (Created by Joshua W. Baker)&lt;BR /&gt;custIDCursor = conn.cursor()&lt;BR /&gt;custIDCursor.execute("SELECT c.custno FROM customer c WHERE c.lname = '%s'" % lnameValue)&lt;BR /&gt;custIDValue = custIDCursor.fetchall()&lt;BR /&gt;print(custIDValue)&lt;/P&gt;&lt;P&gt;custCursor = conn.cursor()&lt;BR /&gt;custCursor.execute("SELECT c.fname, c.lname, c.city FROM customer c WHERE c.custno = '%s' " % custIDValue)&lt;/P&gt;&lt;P&gt;delivCursor = conn.cursor()&lt;BR /&gt;delivCursor.execute("SELECT b.bagno, b.deliverydatetime, b.runno FROM bag b WHERE b.custno = '%s' " % custIDValue)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 20:58:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1169584#M64449</guid>
      <dc:creator>JoshuaBaker2</dc:creator>
      <dc:date>2022-04-30T20:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: cx_Oracle error "SQL Statement not properly ended</title>
      <link>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1169636#M64458</link>
      <description>&lt;P&gt;What happens when you add&lt;/P&gt;&lt;P&gt;custValue = custCursor.fetchall()&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;delivValue = delivCursor.fetchall()&lt;/P&gt;&lt;P&gt;under your two statements that are erroring?&amp;nbsp; It looks like you are setting them up but not executing them and since you are using the same conn without garbage collecting, the previous is staying open.&lt;/P&gt;&lt;P&gt;You may also trying to set them up in with statements so they are garbage collected and resources released before the next cursor is created using the same conn.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with conn.cursor() as custCursor:
    custCursor.execute(f"SELECT c.fname, c.lname, c.city FROM customer c WHERE c.custno = '{custIDValue}'")
    custValue = custCursor.fetchall()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 03:12:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1169636#M64458</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-05-02T03:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: cx_Oracle error "SQL Statement not properly ended</title>
      <link>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1169802#M64459</link>
      <description>&lt;P&gt;Does the .execute() string need to be terminated with a semicolon?&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 18:26:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1169802#M64459</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-05-02T18:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: cx_Oracle error "SQL Statement not properly ended</title>
      <link>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1170616#M64485</link>
      <description>&lt;P&gt;This is exactly what needed to be done, thanks so much for your help! I’m new to SQL so combining it with python was a struggle for me.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 14:26:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cx-oracle-error-quot-sql-statement-not-properly/m-p/1170616#M64485</guid>
      <dc:creator>JoshuaBaker2</dc:creator>
      <dc:date>2022-05-04T14:26:59Z</dc:date>
    </item>
  </channel>
</rss>

