0

I'm trying to migrate from cx_Oracle 8.1.0 to oracledb 2.5.1 library. Before such query was working:

update command_center set 
            E_ID = :1,
            E_ASPECTS = :2,
            E_CREATED_TIMESTAMP = :3
WHERE e_id = :1
def bulk_insert_or_update_data_to_targets(self, sql, target_data, id_index=0):
    for target_connections, data in target_data:
        for con in target_connections:
            cursor = con.cursor()
            cursor.executemany(sql, data, batcherrors=True)
            if cursor.getbatcherrors():
                self.logger.debug("data: " + str(data))
            cursor.close()

but currently I have following exception:

oracledb.exceptions.DatabaseError: DPY-4009: 4 positional bind values are required but 3 were provided

Is there any chance this could work the same way it worked in cx_Oracle before ... so I guess it retrieved the attribute by array index?

2 Answers 2

1

The latter is preferred because it doesn't run into the kind of issue you see. Even Thick mode has some variances with bind-by-position that depend if you are using SQL or PL/SQL statements.

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

1 Comment

great thick mode is exactly how it worked before. There is already instant client installed. I know about the issues with bind by position, but that's a proprietary application which is going to be replaced, so I just want to keep it alive until then.
0

I think the problem may be due to using :1 twice in the query.

You don't need E_ID = :1 in the SET clause, since you're setting the column to the same value it already has (because of WHERE E_ID = :1). So remove that:

update command_center set 
        E_ID = :1,
        E_ASPECTS = :2,
            E_CREATED_TIMESTAMP = :3
WHERE e_id = :1

1 Comment

I know and I wondered why it's there, but this is some proprietary application with a lot of code and rewriting all of those selects at the moment is not the case

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.