1

I have two list having 100 elements in each (say class_db_col, and class_id_col). I want to push all the items in class_db_col list to one column (say class_result) present in oracle DB.

statement = 'update TRANSFERS_TXN_MT set CLASS_RESULT = :1 where id= :2'
for i in range(len(class_db_col)):
     cursor.execute(statement,(class_id_col[i],class_db_col[i]))
conn.commit() 

getting this error

ORA-01484: arrays can only be bound to PL/SQL statement

can anyone help me with this problem?

2
  • Which version of cx_Oracle are you using? Commented Mar 16, 2018 at 7:58
  • @APC cx-Oracle==6.0.2 Commented Mar 16, 2018 at 8:39

1 Answer 1

1

If you have an array of tuples you can use cursor.executemany() instead. It looks like you have two parallel arrays which you can create tuples out of via this code:

data = list(zip(class_id_col, class_db_col))

This should result in an array that looks like this:

[(1, 4), (2, 6), ..., (8, 15)]

Then you can use this code:

cursor.executemany("update TRANSFERS_TXN_MT set CLASS_RESULT = :1 where id = :2", data)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.