1

I have this python code :

valuesupdatehdr=[(0, '2019-05-03 22:18:22', 'vq-01'), (0, '2019-05-03 22:18:24', 've-01'), (0, '2019-05-03 22:18:24', 'vb-01'), (0, '2019-05-03 22:18:25', 'bv-01'), (0, '2019-05-03 22:18:26', 'bb-01'), (0, '2019-05-03 22:18:27', 'nnn-01'), (0, '2019-05-03 22:18:27', 'mmm-01'), (0, '2019-05-03 22:18:28', 'jj-01'), (0, '2019-05-03 22:18:29', 'kk-01'), (0, '2019-05-03 22:18:30', '66-01'), (0, '2019-05-03 22:18:31', '99-01'), (0, '2019-05-03 22:18:31', '11-01')]
update_HDR="""UPDATE HHR_PENPA SET ACTIVE = TO_NUMBER(:ACTIVO) , INACTIVE_DATE = TO_DATE(:FECHA, 'YYYY-MM-DD HH24:MI:SS')  WHERE ORDERID =TO_CHAR(:ORDERID)""" 
        try:
            print("UPDATE en  HHR_PENPA")
            cursor.executemany(update_HDR, valuesupdatehdr)
            miConexion.commit()
        except Exception as e:
            print(str(e) + " ERROR  HHR_PENPA " + update_HDR + " " + str(valuesupdatehdr))
            miConexion.rollback()
            miConexion.commit()

When i run get me this problem.

ORA-00911: invalid character 

By other hand if run this :

UPDATE HHR_PENPA SET ACTIVE = TO_NUMBER(0) , INACTIVE_DATE = TO_DATE('2019-05-03 22:18:22', 'YYYY-MM-DD HH24:MI:SS')  WHERE ORDERID =TO_CHAR('vq-01')

Update correctly.

  • Since you're using named placeholders, shouldn't the elements of `valuesupdatehdr` be dictionaries? – Barmar May 03 '19 at 22:55
  • Maybe something is wrong with your datatypes? I used a table `CREATE TABLE hhr_penpa ( active number,inactive_date date,ORDERID varchar2(20));` and your code worked for me. – Kaushik Nayak May 04 '19 at 05:33
  • By the way, there's no difference between `TO_CHAR('vq-01')` and `'vq-01'` – Barbaros Özhan May 04 '19 at 08:23

0 Answers0