@@ -291,6 +291,8 @@ UROWID can be bound with type :attr:`oracledb.DB_TYPE_ROWID`.
291291See :ref: `querymetadatadiff `.
292292
293293
294+ .. _dml-returning-bind :
295+
294296DML RETURNING Bind Variables
295297============================
296298
@@ -315,9 +317,28 @@ In the above example, since the WHERE clause matches only one row, the output
315317contains a single item in the list. If the WHERE clause matched multiple rows,
316318the output would contain as many items as there were rows that were updated.
317319
318- No duplicate binds are allowed in a DML statement with a RETURNING clause, and
319- no duplication is allowed between bind variables in the DML section and the
320- RETURNING section of the statement.
320+ The same bind variable placeholder name cannot be used both before and after
321+ the RETURNING clause. For example, if the ``:dept_name `` bind variable is used
322+ both before and after the RETURNING clause:
323+
324+ .. code-block :: python
325+
326+ # a variable cannot be used for both input and output in a DML returning
327+ # statement
328+ dept_name_var = cursor.var(str )
329+ dept_name_var.setvalue(0 , ' Input Department' )
330+ cursor.execute("""
331+ update departments set
332+ department_name = :dept_name || ' EXTRA TEXT'
333+ returning department_name into :dept_name""" ,
334+ dept_name = dept_name_var)
335+
336+ The above example will not update the bind variable as expected, but no error
337+ will be raised if you are using python-oracledb Thick mode. With
338+ python-oracledb Thin mode, the above example returns the following error::
339+
340+ DPY-2048: the bind variable placeholder ":dept_name" cannot be used
341+ both before and after the RETURNING clause in a DML RETURNING statement
321342
322343
323344LOB Bind Variables
0 commit comments