File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2387,7 +2387,7 @@ version of python-oracledb.
23872387
23882388.. data :: NCHAR
23892389
2390- A synonym for :data: `DB_TYPE_NVARCHAR `.
2390+ A synonym for :data: `DB_TYPE_NCHAR `.
23912391
23922392 .. deprecated :: cx_Oracle 8.0
23932393
Original file line number Diff line number Diff line change @@ -215,3 +215,22 @@ To convert dates:
215215 for row in cursor:
216216 print (row) # gives 'Mi 15 Dez 19:57:56 2021'
217217 print ()
218+
219+ Inserting NVARCHAR2 and NCHAR Data
220+ ----------------------------------
221+
222+ To bind NVARCHAR2 data, use :func: `Cursor.setinputsizes() ` or create a bind
223+ variable with the correct type by calling :func: `Cursor.var() `. This removes
224+ an internal character set conversion to the standard `Database Character Set `_
225+ that may corrupt data. By binding as :data: `oracledb.DB_TYPE_NVARCHAR `, the
226+ data is inserted directly as the `Database National Character Set `_. For
227+ example, to insert into a table containing two NVARCHAR2 columns:
228+
229+ .. code-block :: python
230+
231+ sql = " insert into mytable values (:1, :2)"
232+ bv = [' data1' , ' data2' ]
233+ cursor.setinputsizes(oracledb.DB_TYPE_NVARCHAR , oracledb.DB_TYPE_NVARCHAR )
234+ cursor.execute(sql, bv)
235+
236+ For NCHAR data, bind as :data: `oracledb.DB_TYPE_NCHAR `.
You can’t perform that action at this time.
0 commit comments