Search code examples
pythonoracle-sqldevelopercx-oracle

ORA-01036: illegal variable name/number Update executemany with cx_orcale


I need to update around 0.5 million rows in oracle sql but I am getting below error when i tried for just 2 rows .I am not understanding as to where I am going wrong .

Error :

    cursor.executemany(updatequery,insert_chunk)
    cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number

MY code:

    insert_batch_size=100000
    bind_update=[['BAIPS9419N', 'AADHAARSEEDINGISSUCCESSFUL'], ['ADOPL3293P', 'AADHAARSEEDINGISSUCCESSFUL']]
    try:
        bind_update_chunks = [bind_update[x:x+insert_batch_size] for x in range(0, len(bind_update), insert_batch_size)]
        for insert_chunk in bind_update_chunks:
            _updatequery="update UCIDBA.client_code_dtls set ccd_aadhaar_seeding_status = 'N',CCD_LST_MOD_BY='SYSTEM',CCD_LST_MOD_DT=SYSDATE where CCD_PAN_NO= :1"
            logging.info("UpdateDBWith_Y:->Update Query : |" +updatequery)
            cursor.executemany(updatequery,insert_chunk)
            connection.commit()
        return True
    except Exception  as e :
        logging.exception("UpdateDBWith_Y:->: |")  
        return False

Solution

  • In your example you have one bind variable (:1) but you have two pieces of data in each row. Adjust the SQL to include a second bind variable (:2) or adjust your data to only supply one piece of data.

    I agree that the error message is a little unhelpful. Efforts are underway to address that for a future release!