Skip to content

ibm_db execute_many() is not working as expected for BLOB and CLOB data type. #1043

@Manojkumarbyibm

Description

@Manojkumarbyibm

Version:
Db2 = v13

Description:
I am trying to run python program which invokes execute_many for performing multi row insert for CLOB and BLOB data type . It is noticed that the function ibm_db.execute_many is not working as expected, which was suppose to execute bulk inserts.

Error:
[IBM][CLI Driver][DB2] SQL0302N  The value of a host variable in the EXECUTE or OPEN statement is out of range for its corresponding use.  SQLSTATE=22001  SQLCODE=-302 (this is a workaround for a bug in ibm_db where the error message does not display correctly)

Note: We verified that values of the CLOB and BLOB input variable are valid and within range of target column.
Also same data was executed successfully using ibm_db.execute(stmt).

Code:

insert = "INSERT INTO MANOJKU.TABLE_ORDER5 (ORDER_ID,ORDER_DISTRICT_ID,ORDER_WAREHOUSE_ID,ORDER_CREATE_CLOB1,ORDER_CREATE_BLOB1) VALUES (?,?,?,?,?)"
data2 = [(0, 'V', 223001281, 'hi', b'\x88\x85\x93\x93\x96'), (0, 'G', 336199306, 'hi', b'\x88\x85\x93\x93\x96')]

try:
conn = ibm_db.connect(conn_str,'','')
if ibm_db.active(conn):
try:
stmt = ibm_db.prepare(conn, insert)
if stmt:
ibm_db.execute_many(stmt,data2)
ibm_db.commit(conn)
print(f"Program inserted rows : {row}")
except:
print(f"Error is {ibm_db.stmt_error()} and error message {ibm_db.stmt_errormsg()}")
except:
print(f"connection to database is not successful")
print(f"Error :{ibm_db.conn_error()}")
print(f"Message :{ibm_db.conn_errormsg()}")
finally:
print(f"Program execution ended ")

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions