[cx-oracle-users] setinputsizes problem?
Brought to you by:
atuining
From: Jason B. <jb...@gm...> - 2010-07-03 16:52:07
|
Hello - I'm using the cx_oracle module for an insertion whose sql is created dynamically. The relevant code is: while staging_row != None: sqlstring = sectionconfig["INSERTIONSQL1"] valuesstring = " VALUES (" rownum += 1 isfirst = True clobs = [] inputsizes = [] for cidx in range(len(colnames)): if (isfirst): isfirst = False else: valuesstring += "," try: curval = staging_row[colnames[cidx]] if (len(curval) > 4000): clobs.append(curval) inputsizes.append(cx_Oracle.CLOB) valuesstring += ":" + str(len(clobs)) else: inputsizes.append(None) valuesstring += curval except Exception: log.exception("Unable to get field value) executestring = sqlstring + valuesstring + ")" #log.debug(executestring) try: #log.debug(executestring) if (len(clobs) == 0): destination_cursor.setinputsizes(inputsizes) destination_cursor.execute(executestring) else: destination_cursor.execute(executestring, clobs) except Exception: e = sys.exc_info()[1] log.error("Could not insert: %s" % e) log.error(executestring) I get the following error: Could not insert: expecting an array of two elements [type, numelems] I thought the argument to setinputsizes was supposed to be an array whose length was the number of columns. Why does it expect a 2-element array? Note that I need to construct the sql dynamically and use CLOB by position, so explicitly doing omething like setinputsizes(value1=cx_Oracle.CLOB, . . .) isn't an option. Running v5.03 for python 2.6 Thanks for any help. |