@things-factory/integration-base 6.1.115 → 6.1.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/images/oracle-procedure-example1.png +0 -0
- package/assets/images/oracle-procedure-example2.png +0 -0
- package/dist-server/engine/task/oracle-procedure.js +17 -10
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/integration/task/oracle-procedure.ko.md +135 -0
- package/helps/integration/task/oracle-procedure.md +136 -0
- package/package.json +8 -8
- package/server/engine/task/oracle-procedure.ts +28 -11
@@ -0,0 +1,135 @@
|
|
1
|
+
# Oracle Procedure Task
|
2
|
+
|
3
|
+
Oracle 데이터베이스에 저장되어 있는 프로시저를 호출하는 태스크이며,
|
4
|
+
개별 데이터 타입에 따라서 데이터의 리스트 혹은 특정 데이터 타입의 값을 반환한다.
|
5
|
+
|
6
|
+
## Parameters
|
7
|
+
|
8
|
+
### 프로시저
|
9
|
+
- 프로시저를 호출하는 함수부를 작성한다. 작성 시에 BEGIN과 END는 실제 내부에서 추가되기 때문에 별도로 지정할 필요가 없다.
|
10
|
+
- 호출 이후에 ;을 추가해야 한다.
|
11
|
+
- 프로시저의 입출력 파라미터는 :과 함께 사용한다.
|
12
|
+
- 프로시저 작성 예는 다음과 같다.
|
13
|
+
|
14
|
+
```sql
|
15
|
+
mcs.myproc(:id, :out_name);
|
16
|
+
```
|
17
|
+
|
18
|
+
### 파라미터
|
19
|
+
- 파라미터는 다음과 같은 요소로 구성되어 있다.
|
20
|
+
- 파라미터 이름
|
21
|
+
- 입출력 지정: IN, INOUT, OUT
|
22
|
+
- 파라미터 타입: String, Number, Date, Cursor
|
23
|
+
- 값: 해당 변수가 입력일 경우, 해당 입력에 대한 값
|
24
|
+
- 최대크기: 해당 변수타입이 String이나 Buffer일 경우, 변수의 최대 크기를 지정.
|
25
|
+
|
26
|
+
#### 파라미터 이름
|
27
|
+
|
28
|
+
파라미터 이름은 프로시저 작성에 사용된 파라미터의 이름을 지정한다.
|
29
|
+
앞의 예의 경우,
|
30
|
+
```sql
|
31
|
+
mcs.myproc(:id, :out_name);
|
32
|
+
```
|
33
|
+
id와 out_name이 각각 파라미터 이름이다.
|
34
|
+
|
35
|
+
### 입출력 지정
|
36
|
+
|
37
|
+
해당 변수가 입력(IN) 혹은 출력(OUT) 여부를 지정한다.
|
38
|
+
|
39
|
+
### 파라미터 타입
|
40
|
+
|
41
|
+
파라미터 타입을 지정한다. 타입은 실제 프로시저 생성 시에 지정되어 있는 이름과 동일하게 지정되어야 한다.
|
42
|
+
|
43
|
+
프로시저가 다음과 같이 구현되어 있다면,
|
44
|
+
|
45
|
+
```sql
|
46
|
+
CREATE OR REPLACE NONEDITIONABLE PROCEDURE myproc (in_id IN VARCHAR2, out_name OUT VARCHAR2) AS
|
47
|
+
BEGIN
|
48
|
+
SELECT name INTO out_name FROM MCS.FMB_USERS WHERE id = in_id ;
|
49
|
+
END;
|
50
|
+
```
|
51
|
+
|
52
|
+
첫번째 파라미터와 두번째 파라미터 모두 VARCHAR2로 지정되어 있으며,
|
53
|
+
|
54
|
+
이러한 프로시저를 호출해야 할 경우 파라미터 타입은 모두 String을 지정해야 하고,
|
55
|
+
출력의 경우, 최대 크기까지 지정해야 한다.
|
56
|
+
|
57
|
+
호출 지정 예는 다음과 같다.
|
58
|
+
|
59
|
+

|
60
|
+
|
61
|
+
|
62
|
+
### 접근자 [accessor](../concept/data-accessor.md)
|
63
|
+
|
64
|
+
설정 방법은 [JSONATA 도큐먼트](http://docs.jsonata.org/overview.html)를 따른다.
|
65
|
+
|
66
|
+
|
67
|
+
### 값
|
68
|
+
|
69
|
+
파라미터가 입력(IN)일 경우, 해당 값을 지정한다.
|
70
|
+
해당 값에 바로 상수 값을 입력하지 않고, 특정 태스크 이름을 지정하도록 한다.
|
71
|
+
|
72
|
+
위의 예어서 id의 입력 값을 ID라고 지정되어 있다면, ID 태스크에서 반환되는 값을 입력 값으로 지정한다.
|
73
|
+
|
74
|
+
|
75
|
+
### 최대 크기
|
76
|
+
|
77
|
+
파라미터 타입이 String이나 Buffer 일 경우, 최대 크기를 지정한다. 다른 타입의 경우 값을 지정하지 않고 무시한다.
|
78
|
+
|
79
|
+
## 태스크 결과
|
80
|
+
|
81
|
+
프로시저 호출에 대한 결과는 Object 형태로 반환되며, 파라미터 중에서 출력으로 지정된 파라미터 이름이 키가 되어 값을 반환한다.
|
82
|
+
|
83
|
+
만약, 위에서 소개된 태스크의 경우 다음과 같은 결과 값을 반환한다.
|
84
|
+
|
85
|
+
```javascript
|
86
|
+
{
|
87
|
+
out_name: 'Admin'
|
88
|
+
}
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
## 다른 사용 예(커서)
|
93
|
+
|
94
|
+
### 프로시저 작성 예
|
95
|
+
|
96
|
+
```sql
|
97
|
+
CREATE OR REPLACDE NONEDITIONABLE PROCEDURE PROCEDURE1(out_cursor OUT SYS_REFCURSOR) AS
|
98
|
+
BEGIN
|
99
|
+
BEGIN
|
100
|
+
OPEN out_cursor FOR
|
101
|
+
SELECT * FROM FARMWEATHER WHERE rownum <= 1000;
|
102
|
+
END;
|
103
|
+
END PROCEDURE1;
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
### 프로시저 호출 예
|
108
|
+
|
109
|
+

|
110
|
+
|
111
|
+
### 프로시저 태스크 호출 결과
|
112
|
+
|
113
|
+
```javascript
|
114
|
+
{
|
115
|
+
"out_cursor": [
|
116
|
+
{
|
117
|
+
"FARMDATE": "2006-01-07T15:00:00.000Z",
|
118
|
+
"MAXT": 29.5,
|
119
|
+
"MINT": 21.8,
|
120
|
+
"WINDSPEED": 1.6,
|
121
|
+
"FARMHUM": 70.2,
|
122
|
+
"PRECIPITATION": 0
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"FARMDATE": "2006-01-08T15:00:00.000Z",
|
126
|
+
"MAXT": 30.1,
|
127
|
+
"MINT": 21,
|
128
|
+
"WINDSPEED": 1.6,
|
129
|
+
"FARMHUM": 67.4,
|
130
|
+
"PRECIPITATION": 0
|
131
|
+
},
|
132
|
+
..
|
133
|
+
]
|
134
|
+
}
|
135
|
+
```
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Oracle Procedure Task
|
2
|
+
|
3
|
+
A task that calls a procedure stored in an Oracle database,
|
4
|
+
Depending on the individual data type, it returns a list of data or a value of a specific data type.
|
5
|
+
|
6
|
+
## Parameters
|
7
|
+
|
8
|
+
### Procedure
|
9
|
+
- Write a function that calls the procedure. You don't need to specify BEGIN and END at the time of writing because they are actually added internally.
|
10
|
+
- You need to add ;after the call.
|
11
|
+
- The input and output parameters of a procedure are used with :.
|
12
|
+
- An example of writing a procedure is as follows
|
13
|
+
|
14
|
+
```sql
|
15
|
+
mcs.myproc(:id, :out_name);
|
16
|
+
```
|
17
|
+
|
18
|
+
### Parameters
|
19
|
+
- A parameter consists of the following elements
|
20
|
+
- The parameter name
|
21
|
+
- Input/output designation: IN, INOUT, OUT
|
22
|
+
- Parameter type: String, Number, Date, Cursor
|
23
|
+
- Value: If the variable is an input, the value for that input.
|
24
|
+
- MaxSize: If the variable is of type String or Buffer, specifies the maximum size of the variable.
|
25
|
+
|
26
|
+
#### Paramter name
|
27
|
+
|
28
|
+
Parameter name specifies the name of the parameter used in the procedure.
|
29
|
+
For the previous example,
|
30
|
+
|
31
|
+
```sql
|
32
|
+
mcs.myproc(:id, :out_name);
|
33
|
+
```
|
34
|
+
|
35
|
+
id and out_name are the parameter names, respectively.
|
36
|
+
|
37
|
+
### In/Out Type
|
38
|
+
|
39
|
+
Specifies whether the variable is an input (IN) or output (OUT).
|
40
|
+
|
41
|
+
### Paramter type
|
42
|
+
|
43
|
+
Specifies the parameter type. The type must be the same as the name given to the actual procedure when it is created.
|
44
|
+
|
45
|
+
If the procedure is implemented as follows,
|
46
|
+
|
47
|
+
```sql
|
48
|
+
CREATE OR REPLACE NONEDITIONABLE PROCEDURE myproc (in_id IN VARCHAR2, out_name OUT VARCHAR2) AS
|
49
|
+
BEGIN
|
50
|
+
SELECT name INTO out_name FROM MCS.FMB_USERS WHERE id = in_id ;
|
51
|
+
END;
|
52
|
+
```
|
53
|
+
|
54
|
+
Both the first and second parameters are specified as VARCHAR2,
|
55
|
+
|
56
|
+
If you need to call these procedures, the parameter types should all be String,
|
57
|
+
For the output, the maximum size should be specified.
|
58
|
+
|
59
|
+
An example call specification is as follows
|
60
|
+
|
61
|
+

|
62
|
+
|
63
|
+
|
64
|
+
# Accessor [accessor](../concept/data-accessor.md)
|
65
|
+
|
66
|
+
- Set when you want to propagate only a part of the data object of the source component or the transformed data.
|
67
|
+
- The setting method follows [JSONATA document](http://docs.jsonata.org/overview.html).
|
68
|
+
|
69
|
+
### Value(for Input)
|
70
|
+
|
71
|
+
If the parameter is an input (IN), specify its value.
|
72
|
+
Do not enter a constant value directly into the value, but rather specify a specific task name.
|
73
|
+
|
74
|
+
In the example above, if the input value for id is specified as ID, specify the value returned by the ID task as the input value.
|
75
|
+
|
76
|
+
### Maxsize
|
77
|
+
|
78
|
+
If the parameter type is String or Buffer, specify the maximum size. For other types, no value is specified and it is ignored.
|
79
|
+
|
80
|
+
## Task Result
|
81
|
+
|
82
|
+
The result of a procedure call is returned as an Object, where the name of the parameter specified as output is the key, and the value is returned.
|
83
|
+
|
84
|
+
For example, the task introduced above returns the following result value.
|
85
|
+
|
86
|
+
```javascript
|
87
|
+
{
|
88
|
+
out_name: 'Admin'
|
89
|
+
}
|
90
|
+
```
|
91
|
+
|
92
|
+
|
93
|
+
## Another Example(using cursor)
|
94
|
+
|
95
|
+
### Procedure using cursor parameter
|
96
|
+
|
97
|
+
```sql
|
98
|
+
CREATE OR REPLACDE NONEDITIONABLE PROCEDURE PROCEDURE1(out_cursor OUT SYS_REFCURSOR) AS
|
99
|
+
BEGIN
|
100
|
+
BEGIN
|
101
|
+
OPEN out_cursor FOR
|
102
|
+
SELECT * FROM FARMWEATHER WHERE rownum <= 1000;
|
103
|
+
END;
|
104
|
+
END PROCEDURE1;
|
105
|
+
|
106
|
+
```
|
107
|
+
|
108
|
+
### Task example to call the procedure using a cursor as an output
|
109
|
+
|
110
|
+

|
111
|
+
|
112
|
+
### Task result
|
113
|
+
|
114
|
+
```javascript
|
115
|
+
{
|
116
|
+
"out_cursor": [
|
117
|
+
{
|
118
|
+
"FARMDATE": "2006-01-07T15:00:00.000Z",
|
119
|
+
"MAXT": 29.5,
|
120
|
+
"MINT": 21.8,
|
121
|
+
"WINDSPEED": 1.6,
|
122
|
+
"FARMHUM": 70.2,
|
123
|
+
"PRECIPITATION": 0
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"FARMDATE": "2006-01-08T15:00:00.000Z",
|
127
|
+
"MAXT": 30.1,
|
128
|
+
"MINT": 21,
|
129
|
+
"WINDSPEED": 1.6,
|
130
|
+
"FARMHUM": 67.4,
|
131
|
+
"PRECIPITATION": 0
|
132
|
+
},
|
133
|
+
...
|
134
|
+
]
|
135
|
+
}
|
136
|
+
```
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-base",
|
3
|
-
"version": "6.1.
|
3
|
+
"version": "6.1.117",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -26,12 +26,12 @@
|
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
28
|
"@apollo/client": "^3.6.9",
|
29
|
-
"@things-factory/api": "^6.1.
|
30
|
-
"@things-factory/auth-base": "^6.1.
|
31
|
-
"@things-factory/env": "^6.1.
|
32
|
-
"@things-factory/oauth2-client": "^6.1.
|
33
|
-
"@things-factory/scheduler-client": "^6.1.
|
34
|
-
"@things-factory/shell": "^6.1.
|
29
|
+
"@things-factory/api": "^6.1.116",
|
30
|
+
"@things-factory/auth-base": "^6.1.116",
|
31
|
+
"@things-factory/env": "^6.1.116",
|
32
|
+
"@things-factory/oauth2-client": "^6.1.116",
|
33
|
+
"@things-factory/scheduler-client": "^6.1.116",
|
34
|
+
"@things-factory/shell": "^6.1.116",
|
35
35
|
"async-mqtt": "^2.5.0",
|
36
36
|
"chance": "^1.1.11",
|
37
37
|
"cross-fetch": "^3.0.4",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"devDependencies": {
|
47
47
|
"@types/cron": "^2.0.1"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "82d5cb1eab1ce608345fba651a221082c47915f5"
|
50
50
|
}
|
@@ -10,7 +10,14 @@ try {
|
|
10
10
|
logger.error('oracledb module loading failed')
|
11
11
|
}
|
12
12
|
|
13
|
-
type ProcedureParameterType = {
|
13
|
+
type ProcedureParameterType = {
|
14
|
+
name: string
|
15
|
+
dir: string
|
16
|
+
type: string
|
17
|
+
val?: any
|
18
|
+
accessor?: string
|
19
|
+
maxSize?: number
|
20
|
+
}
|
14
21
|
|
15
22
|
const TYPES = {
|
16
23
|
Number: oracledb.NUMBER,
|
@@ -48,20 +55,28 @@ async function OracleProcedure(step, context) {
|
|
48
55
|
|
49
56
|
const procedureParameters =
|
50
57
|
parameters &&
|
51
|
-
parameters.reduce((sum, { name, val, dir, type, maxSize }) => {
|
58
|
+
parameters.reduce((sum, { name, val, dir, type, accessor, maxSize }) => {
|
52
59
|
sum[name] = {
|
53
60
|
dir: DIR[dir],
|
54
|
-
type: TYPES[type]
|
55
|
-
val: access(val, data),
|
56
|
-
maxSize
|
61
|
+
type: TYPES[type]
|
57
62
|
}
|
58
63
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
const calculated = val !== undefined ? val : accessor ? access(accessor, data) : undefined
|
65
|
+
|
66
|
+
if (calculated !== undefined) {
|
67
|
+
sum[name].val =
|
68
|
+
type == 'Date'
|
69
|
+
? new Date(calculated)
|
70
|
+
: type == 'Number'
|
71
|
+
? Number(calculated)
|
72
|
+
: type == 'String'
|
73
|
+
? String(calculated)
|
74
|
+
: calculated
|
75
|
+
}
|
76
|
+
|
77
|
+
if (maxSize) {
|
78
|
+
sum[name].maxSize = maxSize
|
79
|
+
}
|
65
80
|
|
66
81
|
return sum
|
67
82
|
}, {})
|
@@ -103,4 +118,6 @@ OracleProcedure.parameterSpec = [
|
|
103
118
|
}
|
104
119
|
]
|
105
120
|
|
121
|
+
OracleProcedure.help = 'integration/task/oracle-procedure'
|
122
|
+
|
106
123
|
TaskRegistry.registerTaskHandler('oracle-procedure', OracleProcedure)
|