25.41 WRITE Procedure Signature 7
This procedure writes an array with all rows that the cursor returns. Each row is a separate object. If the query contains object type, collection, or cursor columns, the procedure uses write(xmltype) to generate JSON. Otherwise, it uses DBMS_SQL to fetch rows and the write() procedures for the appropriate column data types for output. If the column type is varchar2 and the uppercase value is 'TRUE' or 'FALSE', it generates boolean values.
Syntax
APEX_JSON.WRITE (
p_cursor IN OUT NOCOPY sys_refcursor );Parameters
Table 25-51 WRITE Procedure Parameters
| Parameter | Description |
|---|---|
|
p_cursor |
The cursor. |
Example 1
This example writes an array containing JSON objects for departments 10 and 20.
DECLARE
c sys_refcursor;
BEGIN
open c for select deptno, dname, loc from dept where deptno in (10, 20);
apex_json.write(c);
END;
This is the output:
[ { "DEPTNO":10 ,"DNAME":"ACCOUNTING" ,"LOC":"NEW YORK" }
, { "DEPTNO":20 ,"DNAME":"RESEARCH" ,"LOC":"DALLAS" } ]Parent topic: APEX_JSON