forked from doberkofler/PLSQL-JSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_utils.pks
More file actions
89 lines (72 loc) · 3.54 KB
/
json_utils.pks
File metadata and controls
89 lines (72 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
CREATE OR REPLACE
PACKAGE json_utils
IS
----------------------------------------------------------
-- get the number of nodes
--
FUNCTION getNodeCount(theNodes IN json_nodes) RETURN BINARY_INTEGER;
----------------------------------------------------------
-- get the node id for the given property name
--
FUNCTION getNodeIDByName(theNodes IN json_nodes, thePropertyName IN VARCHAR2) RETURN BINARY_INTEGER;
----------------------------------------------------------
-- get the node id for the given property 1-relative index
--
FUNCTION getNodeIDByIndex(theNodes IN json_nodes, thePropertyIndex IN NUMBER) RETURN BINARY_INTEGER;
----------------------------------------------------------
-- validate the given list of nodes and raise an
-- exception with id -20100, if an inconsistency is found
--
PROCEDURE validate(theNodes IN OUT NOCOPY json_nodes);
----------------------------------------------------------
-- add a new node to the list of nodes
--
FUNCTION addNode(theNodes IN OUT NOCOPY json_nodes, theNode IN json_node) RETURN BINARY_INTEGER;
----------------------------------------------------------
-- add a new node to the list of nodes and update the
-- next id pointer in the previous node
--
FUNCTION addNode(theNodes IN OUT NOCOPY json_nodes, theLastID IN OUT NOCOPY NUMBER, theNode IN json_node) RETURN BINARY_INTEGER;
----------------------------------------------------------
-- copy nodes to a new target node
--
PROCEDURE copyNodes(theTargetNodes IN OUT NOCOPY json_nodes, theTargetNodeID IN BINARY_INTEGER, theLastID IN OUT NOCOPY NUMBER, theName IN VARCHAR2, theSourceNodes IN json_nodes);
----------------------------------------------------------
-- create subtree of nodes
--
FUNCTION createSubTree(theSourceNodes IN json_nodes, theSourceNodeID IN BINARY_INTEGER) RETURN json_value;
----------------------------------------------------------
-- convert a node value to a JSON string
--
PROCEDURE value_to_clob(theLobBuf IN OUT NOCOPY CLOB, theStrBuf IN OUT NOCOPY VARCHAR2, theNodes IN json_nodes, theNodeID IN NUMBER);
----------------------------------------------------------
-- convert an object to a JSON string
--
PROCEDURE object_to_clob(theLobBuf IN OUT NOCOPY CLOB, theStrBuf IN OUT NOCOPY VARCHAR2, theNodes IN json_nodes, theNodeID IN NUMBER, theFlushToLOB IN BOOLEAN DEFAULT TRUE);
----------------------------------------------------------
-- convert an array to a JSON string
--
PROCEDURE array_to_clob(theLobBuf IN OUT NOCOPY CLOB, theStrBuf IN OUT NOCOPY VARCHAR2, theNodes IN json_nodes, theNodeID IN NUMBER, theFlushToLOB IN BOOLEAN DEFAULT TRUE);
----------------------------------------------------------
-- add a string to a CLOB
-- (this operation uses a string buffer cache)
--
PROCEDURE add_to_clob(theLobBuf IN OUT NOCOPY CLOB, theStrBuf IN OUT NOCOPY VARCHAR2, theString IN VARCHAR2);
----------------------------------------------------------
-- flush the string buffer cache to the CLOB
--
PROCEDURE flush_clob(theLobBuf IN OUT NOCOPY CLOB, theStrBuf IN OUT NOCOPY VARCHAR2);
----------------------------------------------------------
-- erase the content of a CLOB
--
PROCEDURE erase_clob(theLobBuf IN OUT NOCOPY CLOB);
----------------------------------------------------------
-- escape the string
--
FUNCTION escape(theString IN VARCHAR2, theAsciiOutput IN BOOLEAN DEFAULT TRUE, theEscapeSolitus IN BOOLEAN DEFAULT FALSE) RETURN VARCHAR2;
----------------------------------------------------------
-- copy output to the browser using htp.prn
--
PROCEDURE htp_output_clob(theLobBuf IN CLOB, theJSONP IN VARCHAR2 DEFAULT NULL);
END json_utils;
/