0

While executing the code, nearly 50% of the total records are getting inserted. All of a sudden program stops with the mentioned errors

CODE:

conn = ibm_db.connect('DRIVER={IBM DB2 DRIVER};DATABASE=DEV;HOSTNAME=cloud.ibm.com;PORT=30000;PROTOCOL=TCPIP;UID=userid;pwd=password','','')
conni = ibm_db_dbi.Connection(conn)
subset = df[['col1', 'col2', 'col3', 'col4', 'col5',
       'col6', 'col7', 'col8', 'col9']]

tuple_of_tuples = tuple([tuple(x) for x in subset.values])

load_db2_sql = "INSERT INTO edw.DETAILS VALUES(?,?,?,?,?,?,?,?,?)"

stmt = ibm_db.prepare(conn, load_db2_sql)

ibm_db.execute_many(stmt, tuple_of_tuples)

Error:

Error 1064: Value parameters array 3386 is not homogeneous with previous parameters array

SQLCODE=-302 BM][CLI Driver][DB2/LINUXX8664] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is out of range for its corresponding use. SQLSTATE=22001

1
  • 2
    It seems like a data issue. Can you provide an example (limited) data set which fails? Most likely place to check is around the index of 3386 in tuple_of_tuples. Commented Sep 16, 2019 at 21:34

2 Answers 2

1

I ran into this same issue and used Tad's code but instead of 'No Value' I used None. It inserted those Null "values" into the DB2 table.

df = df.where((pd.notnull(df)), None)

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

Comments

1

The dataframe which I was trying to LOAD to DB2 table had 'nan' values. I have replaced it with "No Value'. It worked after that.

df = df.where((pd.notnull(df)), 'No Value')

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.