-
Notifications
You must be signed in to change notification settings - Fork 15
/
jsonnode.tpb
143 lines (132 loc) · 3.47 KB
/
jsonnode.tpb
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
CREATE OR REPLACE
TYPE BODY jsonNode
IS
----------------------------------------------------------
-- jsonNode
--
CONSTRUCTOR FUNCTION jsonNode(SELF IN OUT NOCOPY jsonNode) RETURN SELF AS RESULT
IS
BEGIN
SELF.typ := NULL;
SELF.nam := NULL;
SELF.str := NULL;
SELF.lob := NULL;
SELF.num := NULL;
SELF.dat := NULL;
SELF.par := NULL;
SELF.nex := NULL;
SELF.sub := NULL;
RETURN;
END jsonNode;
----------------------------------------------------------
-- jsonNode (NULL)
--
CONSTRUCTOR FUNCTION jsonNode(SELF IN OUT NOCOPY jsonNode, theName IN VARCHAR2) RETURN SELF AS RESULT
IS
BEGIN
SELF.typ := json_utils.NODE_TYPE_NULL;
SELF.nam := theName;
SELF.str := NULL;
SELF.lob := NULL;
SELF.num := NULL;
SELF.dat := NULL;
SELF.par := NULL;
SELF.nex := NULL;
SELF.sub := NULL;
RETURN;
END jsonNode;
----------------------------------------------------------
-- jsonNode (VARCHAR2)
--
CONSTRUCTOR FUNCTION jsonNode(SELF IN OUT NOCOPY jsonNode, theName IN VARCHAR2, theValue IN VARCHAR2) RETURN SELF AS RESULT
IS
BEGIN
SELF.typ := json_utils.NODE_TYPE_STRING;
SELF.nam := theName;
SELF.str := theValue;
SELF.lob := NULL;
SELF.num := NULL;
SELF.dat := NULL;
SELF.par := NULL;
SELF.nex := NULL;
SELF.sub := NULL;
RETURN;
END jsonNode;
----------------------------------------------------------
-- jsonNode (CLOB)
--
CONSTRUCTOR FUNCTION jsonNode(SELF IN OUT NOCOPY jsonNode, theName IN VARCHAR2, theValue IN CLOB) RETURN SELF AS RESULT
IS
BEGIN
SELF.typ := json_utils.NODE_TYPE_LOB;
SELF.nam := theName;
SELF.str := NULL;
SELF.lob := empty_clob();
SELF.num := NULL;
SELF.dat := NULL;
SELF.par := NULL;
SELF.nex := NULL;
SELF.sub := NULL;
dbms_lob.createtemporary(lob_loc=>SELF.lob, cache=>TRUE, dur=>dbms_lob.session);
IF (dbms_lob.getlength(lob_loc=>theValue) > 0) THEN
dbms_lob.append(dest_lob=>SELF.lob, src_lob=>theValue);
END IF;
RETURN;
END jsonNode;
----------------------------------------------------------
-- jsonNode (NUMBER)
--
CONSTRUCTOR FUNCTION jsonNode(SELF IN OUT NOCOPY jsonNode, theName IN VARCHAR2, theValue IN NUMBER) RETURN SELF AS RESULT
IS
BEGIN
SELF.typ := CASE WHEN theValue IS NOT NULL THEN json_utils.NODE_TYPE_NUMBER ELSE json_utils.NODE_TYPE_NULL END;
SELF.nam := theName;
SELF.str := NULL;
SELF.lob := NULL;
SELF.num := theValue;
SELF.dat := NULL;
SELF.par := NULL;
SELF.nex := NULL;
SELF.sub := NULL;
RETURN;
END jsonNode;
----------------------------------------------------------
-- jsonNode (DATE)
--
CONSTRUCTOR FUNCTION jsonNode(SELF IN OUT NOCOPY jsonNode, theName IN VARCHAR2, theValue IN DATE) RETURN SELF AS RESULT
IS
BEGIN
SELF.typ := CASE WHEN theValue IS NOT NULL THEN json_utils.NODE_TYPE_DATE ELSE json_utils.NODE_TYPE_NULL END;
SELF.nam := theName;
SELF.str := NULL;
SELF.lob := NULL;
SELF.num := NULL;
SELF.dat := theValue;
SELF.par := NULL;
SELF.nex := NULL;
SELF.sub := NULL;
RETURN;
END jsonNode;
----------------------------------------------------------
-- jsonNode (BOOLEAN)
--
CONSTRUCTOR FUNCTION jsonNode(SELF IN OUT NOCOPY jsonNode, theName IN VARCHAR2, theValue IN BOOLEAN) RETURN SELF AS RESULT
IS
aNumber NUMBER;
BEGIN
IF (theValue IS NOT NULL) THEN
aNumber := CASE theValue WHEN TRUE THEN 1 ELSE 0 END;
END IF;
SELF.typ := CASE WHEN theValue IS NOT NULL THEN json_utils.NODE_TYPE_BOOLEAN ELSE json_utils.NODE_TYPE_NULL END;
SELF.nam := theName;
SELF.str := NULL;
SELF.lob := NULL;
SELF.num := aNumber;
SELF.dat := NULL;
SELF.par := NULL;
SELF.nex := NULL;
SELF.sub := NULL;
RETURN;
END jsonNode;
END;
/