Python Forum
Oracle Merge using cx_oracle
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Oracle Merge using cx_oracle
#1
I am facing an issue with the below Merge statement

cur.execute(('MERGE INTO NETSUITE.NET_TRANSACTION_LINES_EV as Target  '
	         'USING (SELECT  * FROM '
	         '(VALUES vals) '
	         'AS s (TRANSACTION_ID, TRANSACTION_LINE_ID, UNIQUE_KEY) '
	         ') AS Source '
	         'ON Target.UNIQUE_KEY = Source.UNIQUE_KEY '
	         'WHEN NOT MATCHED THEN '
	         'INSERT (TRANSACTION_ID, TRANSACTION_LINE_ID, UNIQUE_KEY) VALUES (Source.TRANSACTION_ID, Source.TRANSACTION_LINE_ID, Source.UNIQUE_KEY) '
	         'WHEN MATCHED THEN '
             'UPDATE SET TRANSACTION_ID=Source.TRANSACTION_ID, TRANSACTION_LINE_ID =Source.TRANSACTION_LINE_ID;'
	         .format( vals = [str(i) for i in records])))
i am passing values on the fly.
My records is has data like this :- [[1,2,3] , [7,8,9], [5,7,8]]
which I am assigning to 'vals = [str(i) for i in records])'.
Also the above code which I found on the internet is the syntax for MySQL and not Oracle. I think I would need to select from dual for the values on the fly
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,210 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  MERGE SQL in oracle executemany kaladin 0 3,041 Oct-12-2020, 11:48 AM
Last Post: kaladin
  Installing cx_Oracle 64-bit on AIX Nash 0 1,972 Dec-10-2019, 12:20 AM
Last Post: Nash
  cx_Oracle.DatabaseError: ORA-12541: TNS:no listener ARV 2 10,922 Oct-03-2019, 12:53 PM
Last Post: ARV
  [split] Help with cx_Oracle gnishakamath 0 2,769 Jan-24-2019, 07:01 PM
Last Post: gnishakamath
  Help with cx_Oracle anandoracledba 0 3,210 Dec-04-2018, 02:08 AM
Last Post: anandoracledba
  Getting an error while connecting oracle DB from Python : cx_Oracle.DatabaseError: OR dinesh1393 0 3,502 Oct-25-2018, 02:44 PM
Last Post: dinesh1393
  cx_Oracle module not found error PRADEEP 1 3,249 Sep-12-2018, 11:10 AM
Last Post: Larz60+
  Windows server 2008 SP2 - Python cx_Oracle connection DLL error tpanagoda 2 4,997 Mar-05-2018, 04:35 AM
Last Post: tpanagoda
  Pip install error for cx_Oracle kdamundson 2 10,591 Dec-01-2016, 08:11 PM
Last Post: kdamundson

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020