質問編集履歴
1
ソースコードを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,31 +16,67 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
```
|
19
|
+
```DDL
|
20
20
|
|
21
|
-
|
21
|
+
CREATE TABLE1 TEST1 (
|
22
22
|
|
23
|
-
|
23
|
+
id INT,
|
24
24
|
|
25
|
-
|
25
|
+
name TEXT
|
26
26
|
|
27
|
-
|
27
|
+
)
|
28
28
|
|
29
|
-
"data3" : "ccc"
|
30
29
|
|
31
|
-
}
|
32
30
|
|
31
|
+
CREATE TABLE1 TEST2 (
|
32
|
+
|
33
|
+
number INT,
|
34
|
+
|
35
|
+
address TEXT
|
36
|
+
|
33
|
-
|
37
|
+
)
|
34
38
|
|
35
39
|
```
|
36
40
|
|
37
41
|
|
38
42
|
|
39
|
-
|
43
|
+
```PostgreSQL
|
44
|
+
|
45
|
+
DECLARE data1 TEXT;
|
46
|
+
|
47
|
+
DECLARE data2 TEXT;
|
40
48
|
|
41
49
|
|
42
50
|
|
51
|
+
BEGIN
|
52
|
+
|
53
|
+
SELECT to_json(TEST1) INTO data1 FROM TEST1;
|
54
|
+
|
55
|
+
SELECT to_json(TEST2) INTO data2 FROM TEST2;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
/* 以下のようなJSONにしたい
|
60
|
+
|
61
|
+
{
|
62
|
+
|
63
|
+
"response_data" : {
|
64
|
+
|
43
|
-
data1
|
65
|
+
"data1" : "aaa",
|
66
|
+
|
67
|
+
"data2" : "bbb"
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
*/
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
END
|
78
|
+
|
79
|
+
```
|
44
80
|
|
45
81
|
|
46
82
|
|