oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
345 stars 70 forks source link

Not able to run bulk upserts using merge statements. #359

Closed paarivarik-engineer closed 4 months ago

paarivarik-engineer commented 4 months ago
  1. Describe your new request in detail Consider I'm running below query using executemany and feed my data in form of a list of touples generated from a df or anything. Ideally I was expecting this to work but its not working sadly. can someone suggest if I can do some workout here to make this work because I have been scratching my head for this around days now. apologies if its a already solved issue and someone can point me in the right direction.

  2. Give supporting information about tools and operating systems. Give relevant product version numbers Query : merge into RMS_INTERNAL OLD using ( SELECT :1 as RM_NAME,:2 as ASSIGNING_MONTH, :3 as ASSIGNING_WEEK, :4 as SOURCE, :5 as TOTAL_ASSIGNED, :6 as TOTAL_NOT_QUALIFIED, :7 as TOTAL_QUALIFIED, :8 as TOTAL_CHANGED from dual ) new ON ( OLD.RM_NAME = new.RM_NAME and OLD.ASSIGNING_WEEK = new.ASSIGNING_WEEK and OLD.ASSIGNING_WEEK = new.ASSIGNING_WEEK and OLD.SOURCE = new.SOURCE and OLD.TOTAL_ASSIGNED = new.TOTAL_ASSIGNED and OLD.TOTAL_NOT_QUALIFIED = new.TOTAL_NOT_QUALIFIED and OLD.TOTAL_QUALIFIED = new.TOTAL_QUALIFIED and OLD.TOTAL_CHANGED = new.TOTAL_CHANGED
    ) when matched then update set OLD.ASSIGNING_MONTH = concat(new.RM_NAME,'_updated') when not matched then insert values (new.RM_NAME, new.ASSIGNING_MONTH, new.ASSIGNING_WEEK, new.SOURCE, new.TOTAL_ASSIGNED, new.TOTAL_NOT_QUALIFIED, new.TOTAL_QUALIFIED, new.TOTAL_CHANGED ) ; """

Data : [('test'.. and so on)]

cjbj commented 4 months ago

To save everyone time, can you give a Python script that creates the table and runs to show the error?

paarivarik-engineer commented 4 months ago

nvm understood the problem here in one of 3AM thoughts 😄 . sorted now. Thanks @cjbj