You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:summary: The first column displays the name of the parameter. The second column displays the data type of the parameter. The third column displays the description of the parameter.
690
+
691
+
* - Parameter
692
+
- Data Type
693
+
- Description
694
+
* - ``buf``
695
+
- Buffer
696
+
- The OSON buffer that is to be decoded.
697
+
698
+
See :ref:`osontype` for an example.
699
+
700
+
.. method:: connection.encodeOSON()
701
+
702
+
.. versionadded:: 6.4
703
+
704
+
.. code-block:: javascript
705
+
706
+
encodeOSON(Any value);
707
+
708
+
This synchronous method encodes a JavaScript value to OSON bytes and
709
+
returns a Buffer. This method is useful for inserting OSON bytes directly
710
+
into BLOB columns that have the check constraint ``IS JSON FORMAT OSON``
711
+
enabled.
712
+
713
+
The parameters of the ``connection.encodeOSON()`` are:
:summary: The first column displays the name of the parameter. The second column displays the data type of the parameter. The third column displays the description of the parameter.
721
+
722
+
* - Parameter
723
+
- Data Type
724
+
- Description
725
+
* - ``value``
726
+
- Any
727
+
- The JavaScript value that is to be encoded into OSON bytes. The JavaScript value can be any value supported by `JSON <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-FBC22D72-AA64-4B0A-92A2-837B32902E2C>`__.
:summary: The first column displays the name of the parameter. The second column displays the data type of the parameter. The third column displays the description of the parameter.
176
+
177
+
* - Parameter
178
+
- Data Type
179
+
- Description
180
+
* - ``offset``
181
+
- Number
182
+
- For LOBs of type CLOB and NCLOB, the offset is the position from which the data is to be fetched, in `UCS-2 code points <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-42BCD57A-A380-4ED9-897F-0500A94803D1>`__. UCS-2 code points are equivalent to characters for all but supplemental characters. If supplemental characters are in the LOB, the offset and amount will have to be chosen carefully to avoid splitting a character.
183
+
184
+
For LOBs of type BLOB and BFILE, the offset is the position of the byte from which the data is to be fetched.
185
+
186
+
The default is *1*.
187
+
188
+
The value of ``offset`` must be greater than or equal to *1*.
189
+
190
+
If the ``offset`` specified in :meth:`lob.getData()` exceeds the length of the LOB, then the value *null* is returned.
191
+
* - ``amount``
192
+
- Number
193
+
- For LOBs of type CLOB and NCLOB, the amount is the number of UCS-2 code points to be read from the absolute offset of the CLOB or NCLOB.
194
+
195
+
For LOBs of type BLOB and BFILE, the amount is the number of bytes to be read from the absolute offset of the BLOB or BFILE.
196
+
197
+
The default is the length of the LOB.
198
+
199
+
The value of ``amount`` must be greater than *0*.
200
+
201
+
If the ``amount`` specified in :meth:`lob.getData()` exceeds the length of the LOB, then only the data starting from the offset to the end of the LOB is returned.
202
+
203
+
If the ``amount`` specified in :meth:`lob.getData()` is *0*, then you will get the error ``NJS-005: invalid value for parameter 2``.
169
204
170
205
For queries returning LOB columns, it can be more efficient to use
171
206
:attr:`~oracledb.fetchAsString`, :attr:`~oracledb.fetchAsBuffer`, or
172
207
:ref:`fetchInfo <propexecfetchinfo>` instead of ``lob.getData()``.
173
208
174
209
Note that it is an asynchronous method and requires a round-trip to the
175
-
database:
210
+
database.
176
211
177
212
.. code-block:: javascript
178
213
179
-
constdata=awaitmyLob.getData();
214
+
constdata=awaitmyLob.getData(offset, amount);
215
+
216
+
.. versionchanged:: 6.4
217
+
218
+
The ``offset`` and ``amount`` parameters were added.
#) Enhanced :meth:`~lob.getData` method to accept offset and amount arguments.
16
+
#) Enhanced :meth:`lob.getData()` method to accept ``offset`` and ``amount``
17
+
arguments.
17
18
See `Issue #1643 <https://github.com/oracle/node-oracledb/issues/1643>`__.
18
19
19
-
#) Add support for fetching BLOB columns which have "IS JSON FORMAT OSON"
20
-
constraint enabled in the same way as columns of type JSON.
21
-
In node-oracledb :ref:`Thick mode <enablingthick>` this requires
22
-
Oracle Client 21c or higher. Applications can get this new fetch behaviour
20
+
#) Added support for fetching BLOB columns which have the
21
+
``IS JSON FORMAT OSON`` constraint enabled in the same way as columns of
22
+
type JSON. In node-oracledb :ref:`Thick mode <enablingthick>` this requires
23
+
Oracle Client 21c or later. Applications can get this new fetch behaviour
23
24
by setting the oracledb property :attr:`oracledb.future.oldJsonColumnAsObj`
24
25
to `true`. The default value for this property is `false` which retains
25
26
the existing fetch behaviour.
26
27
In a future version, the new fetch behaviour will become default and
27
28
setting this property will no longer be needed.
28
29
29
-
#) Added methods :meth:`~Connection.decodeOSON` and
30
-
:meth:`~Connection.encodeOSON` to support fetching and inserting into
30
+
#) Added methods :meth:`connection.decodeOSON()` and
31
+
:meth:`connection.encodeOSON()` to support fetching and inserting into
31
32
columns which have the check constraint ``IS JSON FORMAT OSON``
32
-
enabled. Refer `Storing and Managing JSON Data <https://docs.oracle.com/en/database/oracle/oracle-database/19/adjsn/overview-of-storage-and-management-of-JSON-data.html#GUID-26AB85D2-3277-451B-BFAA-9DD45355FCC7>`__
33
+
enabled. See :ref:`osontype` for more information.
33
34
34
35
#) Connections to standby database opened `MOUNTED` return
0 commit comments