|
1 |
| -.. _xmltype: |
2 |
| - |
3 |
| -******************** |
4 |
| -Working with XMLType |
5 |
| -******************** |
6 |
| - |
7 |
| -``XMLType`` columns queried will returns as Strings by default, limited |
8 |
| -to the size of a VARCHAR2. |
9 |
| - |
10 |
| -However, if desired, the SQL query could be changed to return a CLOB, |
11 |
| -for example: |
12 |
| - |
13 |
| -.. code-block:: sql |
14 |
| -
|
15 |
| - const sql = `SELECT XMLTYPE.GETCLOBVAL(res) FROM resource_view`; |
16 |
| -
|
17 |
| -The CLOB can be fetched in node-oracledb as a String or |
18 |
| -:ref:`Lob <lobclass>`. |
19 |
| - |
20 |
| -To insert into an ``XMLType`` column, directly insert a string |
21 |
| -containing the XML, or use a temporary LOB, depending on the data |
22 |
| -length. |
23 |
| - |
24 |
| -.. code-block:: javascript |
25 |
| -
|
26 |
| - const myxml = |
27 |
| - `<Warehouse> |
28 |
| - <WarehouseId>1</WarehouseId> |
29 |
| - <WarehouseName>Melbourne, Australia</WarehouseName> |
30 |
| - <Building>Owned</Building> |
31 |
| - <Area>2020</Area> |
32 |
| - <Docks>1</Docks> |
33 |
| - <DockType>Rear load</DockType> |
34 |
| - <WaterAccess>false</WaterAccess> |
35 |
| - <RailAccess>N</RailAccess> |
36 |
| - <Parking>Garage</Parking> |
37 |
| - <VClearance>20</VClearance> |
38 |
| - </Warehouse>`; |
39 |
| -
|
40 |
| - const result = await connection.execute( |
41 |
| - `INSERT INTO xwarehouses (warehouse_id, warehouse_spec) VALUES (:id, XMLType(:bv))`, |
42 |
| - { id: 1, bv: myxml } |
43 |
| - ); |
44 |
| -
|
45 |
| -LOB handling as discussed in the section :ref:`Working with CLOB, NCLOB and |
46 |
| -BLOB Data <lobhandling>`. |
| 1 | +.. _xmltype: |
| 2 | + |
| 3 | +******************** |
| 4 | +Working with XMLType |
| 5 | +******************** |
| 6 | + |
| 7 | +``XMLType`` columns queried will returns as Strings by default, limited |
| 8 | +to the size of a VARCHAR2. |
| 9 | + |
| 10 | +However, if desired, the SQL query could be changed to return a CLOB, |
| 11 | +for example: |
| 12 | + |
| 13 | +.. code-block:: sql |
| 14 | +
|
| 15 | + const sql = `SELECT XMLTYPE.GETCLOBVAL(res) FROM resource_view`; |
| 16 | +
|
| 17 | +The CLOB can be fetched in node-oracledb as a String or |
| 18 | +:ref:`Lob <lobclass>`. |
| 19 | + |
| 20 | +To insert into an ``XMLType`` column, directly insert a string |
| 21 | +containing the XML, or use a temporary LOB, depending on the data |
| 22 | +length. |
| 23 | + |
| 24 | +.. code-block:: javascript |
| 25 | +
|
| 26 | + const myxml = |
| 27 | + `<Warehouse> |
| 28 | + <WarehouseId>1</WarehouseId> |
| 29 | + <WarehouseName>Melbourne, Australia</WarehouseName> |
| 30 | + <Building>Owned</Building> |
| 31 | + <Area>2020</Area> |
| 32 | + <Docks>1</Docks> |
| 33 | + <DockType>Rear load</DockType> |
| 34 | + <WaterAccess>false</WaterAccess> |
| 35 | + <RailAccess>N</RailAccess> |
| 36 | + <Parking>Garage</Parking> |
| 37 | + <VClearance>20</VClearance> |
| 38 | + </Warehouse>`; |
| 39 | +
|
| 40 | + const result = await connection.execute( |
| 41 | + `INSERT INTO xwarehouses (warehouse_id, warehouse_spec) VALUES (:id, XMLType(:bv))`, |
| 42 | + { id: 1, bv: myxml } |
| 43 | + ); |
| 44 | +
|
| 45 | +LOB handling as discussed in the section :ref:`Working with CLOB, NCLOB and |
| 46 | +BLOB Data <lobhandling>`. |
0 commit comments