web_plsql 0.5.1 → 0.8.0
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/README.md +128 -111
- package/examples/server_apex.js +26 -0
- package/examples/server_sample.js +30 -0
- package/examples/sql/{doc_table.sql → doctable.sql} +1 -1
- package/examples/sql/install.sql +6 -9
- package/examples/sql/sample_package.sql +27 -0
- package/examples/sql/sample_package_body.sql +245 -0
- package/examples/static/sample.css +11 -10
- package/package.json +92 -83
- package/src/cgi.js +127 -0
- package/src/error.js +24 -0
- package/src/errorPage.js +296 -0
- package/src/file.js +95 -0
- package/src/handlerLogger.js +21 -0
- package/src/handlerMetrics.js +46 -0
- package/src/handlerPlSql.js +65 -0
- package/src/handlerUpload.js +32 -0
- package/src/index.js +17 -0
- package/src/oracle.js +80 -0
- package/src/parsePage.js +193 -0
- package/src/procedure.js +260 -0
- package/src/procedureError.js +40 -0
- package/src/procedureNamed.js +233 -0
- package/src/procedureSanitize.js +215 -0
- package/src/procedureVariable.js +57 -0
- package/src/request.js +103 -0
- package/src/{requestError.ts → requestError.js} +8 -4
- package/src/sendResponse.js +104 -0
- package/src/server.js +185 -0
- package/src/shutdown.js +53 -0
- package/src/stream.js +28 -0
- package/src/trace.js +74 -0
- package/src/tty.js +48 -0
- package/src/types.js +146 -0
- package/src/upload.js +92 -0
- package/src/version.js +38 -0
- package/types/cgi.d.ts +4 -0
- package/types/error.d.ts +1 -0
- package/types/errorPage.d.ts +10 -0
- package/types/file.d.ts +6 -0
- package/types/handlerLogger.d.ts +2 -0
- package/types/handlerMetrics.d.ts +4 -0
- package/types/handlerPlSql.d.ts +8 -0
- package/types/handlerUpload.d.ts +7 -0
- package/types/index.d.ts +10 -0
- package/types/oracle.d.ts +5 -0
- package/types/parsePage.d.ts +3 -0
- package/types/procedure.d.ts +10 -0
- package/types/procedureError.d.ts +23 -0
- package/types/procedureNamed.d.ts +14 -0
- package/types/procedureSanitize.d.ts +14 -0
- package/types/procedureVariable.d.ts +9 -0
- package/types/request.d.ts +7 -0
- package/types/requestError.d.ts +8 -0
- package/types/sendResponse.d.ts +4 -0
- package/types/server.d.ts +11 -0
- package/types/shutdown.d.ts +2 -0
- package/types/stream.d.ts +1 -0
- package/types/trace.d.ts +5 -0
- package/types/tty.d.ts +4 -0
- package/types/types.d.ts +251 -0
- package/types/upload.d.ts +5 -0
- package/types/version.d.ts +8 -0
- package/.editorconfig +0 -8
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -347
- package/CHANGELOG.md +0 -133
- package/examples/apex.js +0 -70
- package/examples/credentials.js +0 -22
- package/examples/oracledb_example.js +0 -30
- package/examples/sample.js +0 -101
- package/examples/sql/sample.pkb +0 -223
- package/examples/sql/sample.pks +0 -24
- package/jest.config.js +0 -207
- package/src/cgi.ts +0 -95
- package/src/config.ts +0 -97
- package/src/errorPage.ts +0 -286
- package/src/fileUpload.ts +0 -126
- package/src/index.ts +0 -65
- package/src/page.ts +0 -275
- package/src/procedure.ts +0 -360
- package/src/procedureError.ts +0 -27
- package/src/request.ts +0 -139
- package/src/stream.ts +0 -26
- package/src/trace.ts +0 -194
- package/test/.eslintrc.json +0 -5
- package/test/__tests__/cgi.ts +0 -96
- package/test/__tests__/config.ts +0 -41
- package/test/__tests__/errorPage.ts +0 -101
- package/test/__tests__/oracledb_mock.ts +0 -98
- package/test/__tests__/server.ts +0 -495
- package/test/__tests__/stream.ts +0 -21
- package/test/mock/oracledb.ts +0 -85
- package/test/static/static.html +0 -1
- package/tsconfig.json +0 -24
- package/tsconfig.src.json +0 -23
package/CHANGELOG.md
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
6
|
-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [?.?.?] - ????-??-??
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
### Changed
|
|
12
|
-
### Fixed
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## [0.5.1] - 2022-09-11
|
|
16
|
-
|
|
17
|
-
### Fixed
|
|
18
|
-
- Updated all dependencies.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## [0.5.0] - 2022-05-09
|
|
22
|
-
|
|
23
|
-
### Changed
|
|
24
|
-
- Replaced mocha with jest.
|
|
25
|
-
- Added support for node 18.
|
|
26
|
-
|
|
27
|
-
### Fixed
|
|
28
|
-
- Updated all dependencies.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## [0.4.2] - 2022-01-17
|
|
32
|
-
|
|
33
|
-
### Changed
|
|
34
|
-
- node.js support starting with v16.
|
|
35
|
-
|
|
36
|
-
### Fixed
|
|
37
|
-
- Updated all dependencies.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## [0.4.1] - 2021-08-30
|
|
41
|
-
|
|
42
|
-
### Fixed
|
|
43
|
-
- Updated all dependencies.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [0.4.0] - 2021-04-09
|
|
47
|
-
|
|
48
|
-
### Added
|
|
49
|
-
- Added a simple oracledb example "examples/oracledb_example.js".
|
|
50
|
-
|
|
51
|
-
### Changed
|
|
52
|
-
- The credentials for the "examples/sample.js" are stored in "examples/credentials.js" and can also be set using the environment.
|
|
53
|
-
|
|
54
|
-
### Fixed
|
|
55
|
-
- Updated to oracledb 5 and full binary support for node 14 and later.
|
|
56
|
-
- Updated all minor dependencies.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
## [0.3.2] - 2020-03-29
|
|
60
|
-
|
|
61
|
-
### Fixed
|
|
62
|
-
- Updated all minor dependencies.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## [0.3.1] - 2020-02-19
|
|
66
|
-
|
|
67
|
-
### Fixed
|
|
68
|
-
- Updated all minor dependencies.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## [0.2.0] - 2019-06-02
|
|
72
|
-
|
|
73
|
-
## [0.2.0] - 2019-06-02
|
|
74
|
-
|
|
75
|
-
### Fixed
|
|
76
|
-
- Fixed a problem with the dependencies when installing the npm package.
|
|
77
|
-
- Fixed link to the official oracledb installation documentation.
|
|
78
|
-
- Updated all dependencies.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
## [0.1.2] - 2019-03-02
|
|
82
|
-
|
|
83
|
-
### Fixed
|
|
84
|
-
- Updated all dependencies.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
## [0.1.1] - 2019-02-05
|
|
88
|
-
|
|
89
|
-
### Changed
|
|
90
|
-
- Migrated from Babel to TypeScript
|
|
91
|
-
|
|
92
|
-
### Fixed
|
|
93
|
-
- Updated all dependencies.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
## [0.1.0] - 2018-09-03
|
|
97
|
-
|
|
98
|
-
### Added
|
|
99
|
-
- Added the configuration open "errorStyle" that can be set to "basic" or "debug".
|
|
100
|
-
- The current web_plsql version is now a string property "version" in the middleware object.
|
|
101
|
-
- Added the express status monitor to the sample. (http://localhost:8000/status)
|
|
102
|
-
|
|
103
|
-
### Fixed
|
|
104
|
-
- When downloading a file, first send any eventual "other headers" like "Content-Disposition".
|
|
105
|
-
- Changed x-db-xontent-length to x-db-content-length.
|
|
106
|
-
- Updated all dependencies.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
## [0.0.3] - 2018-03-20
|
|
110
|
-
|
|
111
|
-
### Added
|
|
112
|
-
- Added support for the PlsqlPathAlias and PlsqlPathAliasProcedure DAD settings.
|
|
113
|
-
- Partial support of APEX application.
|
|
114
|
-
- Added example configuration for APEX application.
|
|
115
|
-
- Added unit tests with a code coverage of over 90%.
|
|
116
|
-
|
|
117
|
-
### Fixed
|
|
118
|
-
- Fixed some edge cases when processing the http headers.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
## [0.0.2] - 2018-03-19
|
|
122
|
-
|
|
123
|
-
### Added
|
|
124
|
-
- Allow to add or override CGI environment variables using the "cgi" property in the configuration object.
|
|
125
|
-
- Added unit tests with a code coverage of over 80%.
|
|
126
|
-
|
|
127
|
-
### Fixed
|
|
128
|
-
- Fixed wrong field name when uploading files using a form.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
## [0.0.1] - 2018-03-17
|
|
132
|
-
|
|
133
|
-
- Initial release
|
package/examples/apex.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const express = require('express');
|
|
4
|
-
const bodyParser = require('body-parser');
|
|
5
|
-
const multipart = require('connect-multiparty');
|
|
6
|
-
const cookieParser = require('cookie-parser');
|
|
7
|
-
const compression = require('compression');
|
|
8
|
-
const morgan = require('morgan');
|
|
9
|
-
|
|
10
|
-
const oracledb = require('oracledb');
|
|
11
|
-
const webplsql = require('../lib');
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
* Allocate the Oracle database pool
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const connectionPool = oracledb.createPool({
|
|
18
|
-
user: 'APEX_PUBLIC_USER',
|
|
19
|
-
password: 'manager',
|
|
20
|
-
connectString: 'localhost:1521/TEST',
|
|
21
|
-
poolMin: 10,
|
|
22
|
-
poolMax: 1000,
|
|
23
|
-
poolIncrement: 10,
|
|
24
|
-
queueRequests: false,
|
|
25
|
-
queueTimeout: 1000
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
connectionPool.catch(e => {
|
|
29
|
-
console.error(`Unable to create database pool.\n${e.message}`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
/*
|
|
34
|
-
* Start the server
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
const PORT = 8000;
|
|
38
|
-
const PATH = '/apex';
|
|
39
|
-
const OPTIONS = {
|
|
40
|
-
trace: 'on',
|
|
41
|
-
defaultPage: 'apex',
|
|
42
|
-
doctable: 'wwv_flow_file_objects$',
|
|
43
|
-
pathAlias: {
|
|
44
|
-
alias: 'r',
|
|
45
|
-
procedure: 'wwv_flow.resolve_friendly_url'
|
|
46
|
-
},
|
|
47
|
-
errorStyle: 'debug'
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// create express app
|
|
51
|
-
const app = express();
|
|
52
|
-
|
|
53
|
-
// add middleware
|
|
54
|
-
app.use(multipart());
|
|
55
|
-
app.use(bodyParser.json());
|
|
56
|
-
app.use(bodyParser.urlencoded({extended: true}));
|
|
57
|
-
app.use(cookieParser());
|
|
58
|
-
app.use(compression());
|
|
59
|
-
app.use(morgan('combined', {stream: fs.createWriteStream(path.join(process.cwd(), 'access.log'), {flags: 'a'})}));
|
|
60
|
-
|
|
61
|
-
// add the oracle pl/sql express middleware
|
|
62
|
-
app.use(PATH + '/:name?', webplsql(connectionPool, OPTIONS));
|
|
63
|
-
|
|
64
|
-
// serving static files
|
|
65
|
-
const staticFilesPath = path.resolve('/Middleware/apex/images/');
|
|
66
|
-
app.use('/i/', express.static(staticFilesPath));
|
|
67
|
-
|
|
68
|
-
// listen on port
|
|
69
|
-
console.log(`Listening on http://localhost:${PORT}${PATH}`);
|
|
70
|
-
app.listen(PORT);
|
package/examples/credentials.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Holds the credentials used to connect to the database.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
user : process.env.NODE_ORACLEDB_USER || 'sample',
|
|
7
|
-
|
|
8
|
-
// Get the password from the environment variable
|
|
9
|
-
// NODE_ORACLEDB_PASSWORD. The password could also be a hard coded
|
|
10
|
-
// string (not recommended), or it could be prompted for.
|
|
11
|
-
// Alternatively use External Authentication so that no password is
|
|
12
|
-
// needed.
|
|
13
|
-
password : process.env.NODE_ORACLEDB_PASSWORD || 'sample',
|
|
14
|
-
|
|
15
|
-
// For information on connection strings see:
|
|
16
|
-
// https://oracle.github.io/node-oracledb/doc/api.html#connectionstrings
|
|
17
|
-
connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || 'localhost:1521/test',
|
|
18
|
-
|
|
19
|
-
// Setting externalAuth is optional. It defaults to false. See:
|
|
20
|
-
// https://oracle.github.io/node-oracledb/doc/api.html#extauth
|
|
21
|
-
externalAuth : process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false
|
|
22
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const oracledb = require('oracledb');
|
|
2
|
-
const dbConfig = require('./credentials.js');
|
|
3
|
-
|
|
4
|
-
async function run() {
|
|
5
|
-
let connection;
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
// Connect to database
|
|
9
|
-
connection = await oracledb.getConnection(dbConfig);
|
|
10
|
-
|
|
11
|
-
// Select some data
|
|
12
|
-
binds = {};
|
|
13
|
-
result = await connection.execute('SELECT sysdate FROM dual', binds, {});
|
|
14
|
-
console.log('metadata: ', result.metaData);
|
|
15
|
-
console.log('results: ');
|
|
16
|
-
console.log(result.rows);
|
|
17
|
-
} catch (err) {
|
|
18
|
-
console.error(err);
|
|
19
|
-
} finally {
|
|
20
|
-
if (connection) {
|
|
21
|
-
try {
|
|
22
|
-
await connection.close();
|
|
23
|
-
} catch (err) {
|
|
24
|
-
console.error(err);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
run();
|
package/examples/sample.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const express = require('express');
|
|
4
|
-
const bodyParser = require('body-parser');
|
|
5
|
-
const multipart = require('connect-multiparty');
|
|
6
|
-
const cookieParser = require('cookie-parser');
|
|
7
|
-
const compression = require('compression');
|
|
8
|
-
const morgan = require('morgan');
|
|
9
|
-
|
|
10
|
-
const oracledb = require('oracledb');
|
|
11
|
-
const webplsql = require('../lib');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
* Holds the credentials used by node-oracledb examples to connect
|
|
16
|
-
* to the database. Production applications should consider using
|
|
17
|
-
* External Authentication to avoid hard coded credentials.
|
|
18
|
-
*/
|
|
19
|
-
const dbConfig = require('./credentials.js');
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
* Allocate the Oracle database pool
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const connectionPool = oracledb.createPool({
|
|
26
|
-
user: dbConfig.user, // The database user name.
|
|
27
|
-
password: dbConfig.password, // The password of the database user.
|
|
28
|
-
connectString: dbConfig.connectString, // The Oracle database instance to connect to. The string can be an Easy Connect string, or a Net Service Name from a tnsnames.ora file, or the name of a local Oracle database instance.
|
|
29
|
-
poolMin: 10, // The minimum number of connections a connection pool maintains, even when there is no activity to the target database.
|
|
30
|
-
poolMax: 1000, // The maximum number of connections to which a connection pool can grow.
|
|
31
|
-
poolIncrement: 10, // The number of connections that are opened whenever a connection request exceeds the number of currently open connections.
|
|
32
|
-
queueRequests: false, // If this property is false and a request for a connection is made from a pool where the number of “checked out” connections has reached poolMax, then an ORA-24418 error indicating that further sessions cannot be opened will be returned.
|
|
33
|
-
queueTimeout: 1000 // The number of milliseconds after which connection requests waiting in the connection request queue are terminated. If queueTimeout is 0, then queued connection requests are never terminated.
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
connectionPool.catch(e => {
|
|
37
|
-
console.error(`Unable to create database pool.\n${e.message}`);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
/*
|
|
42
|
-
* Start the server
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
const PORT = 8000;
|
|
46
|
-
const PATH = '/base';
|
|
47
|
-
const OPTIONS = {
|
|
48
|
-
trace: 'on',
|
|
49
|
-
defaultPage: 'sample.pageIndex',
|
|
50
|
-
doctable: 'docTable',
|
|
51
|
-
pathAlias: {
|
|
52
|
-
alias: 'myalias',
|
|
53
|
-
procedure: 'sample.pagePathAlias'
|
|
54
|
-
},
|
|
55
|
-
errorStyle: 'debug'
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// Welcome message
|
|
59
|
-
console.log(`Welcome to web_plsql version ${webplsql.version}!`);
|
|
60
|
-
|
|
61
|
-
// create express app
|
|
62
|
-
const app = express();
|
|
63
|
-
|
|
64
|
-
// add middleware
|
|
65
|
-
app.use(multipart());
|
|
66
|
-
app.use(bodyParser.json());
|
|
67
|
-
app.use(bodyParser.urlencoded({extended: true}));
|
|
68
|
-
app.use(cookieParser());
|
|
69
|
-
app.use(compression());
|
|
70
|
-
app.use(morgan('combined', {stream: fs.createWriteStream(path.join(process.cwd(), 'access.log'), {flags: 'a'})}));
|
|
71
|
-
|
|
72
|
-
// add express status monitor
|
|
73
|
-
app.use(require('express-status-monitor')());
|
|
74
|
-
console.log(`Express status monitor is listening on http://localhost:${PORT}/status`);
|
|
75
|
-
|
|
76
|
-
// add the oracle pl/sql express middleware
|
|
77
|
-
app.use(PATH + '/:name?', webplsql(connectionPool, OPTIONS));
|
|
78
|
-
|
|
79
|
-
// serving static files
|
|
80
|
-
app.use('/static', express.static(path.join(process.cwd(), 'examples/static')));
|
|
81
|
-
|
|
82
|
-
// shutdown
|
|
83
|
-
process.on('SIGTERM', shutDown);
|
|
84
|
-
process.on('SIGINT', shutDown);
|
|
85
|
-
|
|
86
|
-
// listen on port
|
|
87
|
-
console.log(`Sample app is listening on http://localhost:${PORT}${PATH}`);
|
|
88
|
-
const server = app.listen(PORT);
|
|
89
|
-
|
|
90
|
-
function shutDown() {
|
|
91
|
-
console.log('Received kill signal, shutting down gracefully');
|
|
92
|
-
server.close(() => {
|
|
93
|
-
console.log('Closed out remaining connections');
|
|
94
|
-
process.exit(0);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
setTimeout(() => {
|
|
98
|
-
console.error('Could not close connections in time, forcefully shutting down');
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}, 10000);
|
|
101
|
-
}
|
package/examples/sql/sample.pkb
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
CREATE OR REPLACE
|
|
2
|
-
PACKAGE BODY sample IS
|
|
3
|
-
|
|
4
|
-
PROCEDURE openPage(title IN VARCHAR2);
|
|
5
|
-
PROCEDURE closePage;
|
|
6
|
-
|
|
7
|
-
FUNCTION emptyArray RETURN vc_arr
|
|
8
|
-
IS
|
|
9
|
-
arr vc_arr;
|
|
10
|
-
BEGIN
|
|
11
|
-
RETURN arr;
|
|
12
|
-
END emptyArray;
|
|
13
|
-
|
|
14
|
-
PROCEDURE pageIndex(p IN VARCHAR2 DEFAULT NULL)
|
|
15
|
-
IS
|
|
16
|
-
BEGIN
|
|
17
|
-
openPage('web_plsql - Index Page');
|
|
18
|
-
htp.p('<ul>');
|
|
19
|
-
htp.p('<li><a href="sample.pageSimple?text=some-text">Simple page</a></li>');
|
|
20
|
-
htp.p('<li><a href="sample.pageArray?text=some-text'||CHR(38)||'text=more-text'||CHR(38)||'text=last-text">Array passing</a></li>');
|
|
21
|
-
htp.p('<li><a href="!sample.pageFlexible?p1=v1'||CHR(38)||'p2=v2'||CHR(38)||'p3=v3.1'||CHR(38)||'p3=v3.2"">Flexible parameter passing</a></li>');
|
|
22
|
-
htp.p('<li><a href="sample.pageCGI">CGI</a></li>');
|
|
23
|
-
htp.p('<li><a href="sample.pageCookie">Cookies</a></li>');
|
|
24
|
-
htp.p('<li><a href="sample.pageForm">Form</a></li>');
|
|
25
|
-
htp.p('<li><a href="sample.pageFileUpload">File upload</a></li>');
|
|
26
|
-
htp.p('<li><a href="sample.pageRedirect">Redirect</a></li>');
|
|
27
|
-
htp.p('<li><a href="sample.pageLocation">Change location</a></li>');
|
|
28
|
-
htp.p('<li><a href="myalias">pathAlias configuration setting</a></li>');
|
|
29
|
-
htp.p('</ul>');
|
|
30
|
-
closePage();
|
|
31
|
-
END pageIndex;
|
|
32
|
-
|
|
33
|
-
PROCEDURE pageSimple(text IN VARCHAR2 DEFAULT NULL)
|
|
34
|
-
IS
|
|
35
|
-
BEGIN
|
|
36
|
-
openPage('web_plsql - Simple page');
|
|
37
|
-
htp.p('<p>'||text||'</p>');
|
|
38
|
-
closePage();
|
|
39
|
-
END pageSimple;
|
|
40
|
-
|
|
41
|
-
PROCEDURE pageArray(text IN vc_arr)
|
|
42
|
-
IS
|
|
43
|
-
BEGIN
|
|
44
|
-
openPage('web_plsql - Array parameter passing');
|
|
45
|
-
htp.p('<table>');
|
|
46
|
-
htp.p('<tr><th>value</th></tr>');
|
|
47
|
-
FOR i IN 1 .. text.COUNT LOOP
|
|
48
|
-
htp.p('<tr><td>'||text(i)||'</td></tr>');
|
|
49
|
-
END LOOP;
|
|
50
|
-
htp.p('</table>');
|
|
51
|
-
closePage();
|
|
52
|
-
END pageArray;
|
|
53
|
-
|
|
54
|
-
PROCEDURE pageFlexible(name_array IN owa.vc_arr, value_array IN owa.vc_arr)
|
|
55
|
-
IS
|
|
56
|
-
BEGIN
|
|
57
|
-
openPage('web_plsql - Flexible parameter passing');
|
|
58
|
-
htp.p('<table>');
|
|
59
|
-
htp.p('<tr><th>name</th><th>value</th></tr>');
|
|
60
|
-
FOR i IN 1 .. name_array.COUNT LOOP
|
|
61
|
-
htp.p('<tr><td>'||name_array(i)||'</td><td>'||value_array(i)||'</td></tr>');
|
|
62
|
-
END LOOP;
|
|
63
|
-
htp.p('</table>');
|
|
64
|
-
closePage();
|
|
65
|
-
END pageFlexible;
|
|
66
|
-
|
|
67
|
-
PROCEDURE pageCGI
|
|
68
|
-
IS
|
|
69
|
-
BEGIN
|
|
70
|
-
openPage('web_plsql - CGI');
|
|
71
|
-
htp.p('<table>');
|
|
72
|
-
htp.p('<tr><th>name</th><th>value</th></tr>');
|
|
73
|
-
FOR i IN 1 .. owa.num_cgi_vars LOOP
|
|
74
|
-
htp.p('<tr><td>'||owa.cgi_var_name(i)||'</td><td>'||owa.cgi_var_val(i)||'</td></tr>');
|
|
75
|
-
END LOOP;
|
|
76
|
-
htp.p('</table>');
|
|
77
|
-
closePage();
|
|
78
|
-
END pageCGI;
|
|
79
|
-
|
|
80
|
-
PROCEDURE pageCookie
|
|
81
|
-
IS
|
|
82
|
-
names owa_cookie.vc_arr;
|
|
83
|
-
vals owa_cookie.vc_arr;
|
|
84
|
-
num_vals INTEGER;
|
|
85
|
-
BEGIN
|
|
86
|
-
owa_cookie.get_all(names=>names, vals=>vals, num_vals=>num_vals);
|
|
87
|
-
|
|
88
|
-
owa_util.mime_header('text/html', FALSE);
|
|
89
|
-
owa_cookie.send('demoCookie', TO_CHAR(SYSDATE, 'YYYY.MM.DD HH24:MI:SS'));
|
|
90
|
-
owa_util.http_header_close;
|
|
91
|
-
|
|
92
|
-
openPage('web_plsql - Cookies');
|
|
93
|
-
htp.p('<table>');
|
|
94
|
-
htp.p('<tr><th>name</th><th>value</th></tr>');
|
|
95
|
-
FOR i IN 1 .. num_vals LOOP
|
|
96
|
-
htp.p('<tr><td>'||names(i)||'</td><td>'||vals(i)||'</td></tr>');
|
|
97
|
-
END LOOP;
|
|
98
|
-
htp.p('</table>');
|
|
99
|
-
closePage();
|
|
100
|
-
END pageCookie;
|
|
101
|
-
|
|
102
|
-
PROCEDURE pageForm
|
|
103
|
-
IS
|
|
104
|
-
BEGIN
|
|
105
|
-
openPage('web_plsql - Form');
|
|
106
|
-
htp.p('<form method="POST" action="sample.pageFormProcess">');
|
|
107
|
-
htp.p('<table>');
|
|
108
|
-
htp.p('<tr><td>First name:</td><td><input type="text" name="firstname"></td></tr>');
|
|
109
|
-
htp.p('<tr><td>Last name:</td><td><input type="text" name="lastname"></td></tr>');
|
|
110
|
-
htp.p('<tr><td>Age:</td><td><input type="text" name="age"></td></tr>');
|
|
111
|
-
htp.p('<tr><td colspan="2"><input type="radio" name="sex" value="male">Male</td></tr>');
|
|
112
|
-
htp.p('<tr><td colspan="2"><input type="radio" name="sex" value="female">Female</td></tr>');
|
|
113
|
-
htp.p('<tr><td colspan="2"><input type="checkbox" name="vehicle" value="Bike">I have a bike</td></tr>');
|
|
114
|
-
htp.p('<tr><td colspan="2"><input type="checkbox" name="vehicle" value="Car">I have a car </td></tr>');
|
|
115
|
-
htp.p('<tr><td colspan="2"><input type="submit" value="Submit"></td></tr>');
|
|
116
|
-
htp.p('</table>');
|
|
117
|
-
htp.p('</form>');
|
|
118
|
-
closePage();
|
|
119
|
-
END pageForm;
|
|
120
|
-
|
|
121
|
-
PROCEDURE pageFormProcess(firstname IN VARCHAR2 DEFAULT NULL, lastname IN VARCHAR2 DEFAULT NULL, age IN VARCHAR2 DEFAULT NULL, sex IN VARCHAR2 DEFAULT NULL, vehicle IN vc_arr DEFAULT emptyArray)
|
|
122
|
-
IS
|
|
123
|
-
PROCEDURE line(name IN VARCHAR2, value IN VARCHAR2)
|
|
124
|
-
IS
|
|
125
|
-
BEGIN
|
|
126
|
-
htp.p('<tr><th>'||name||'</th><td>'||value||'</td></tr>');
|
|
127
|
-
END line;
|
|
128
|
-
BEGIN
|
|
129
|
-
openPage('web_plsql - Form processed');
|
|
130
|
-
htp.p('<table>');
|
|
131
|
-
line('firstname', firstname);
|
|
132
|
-
line('lastname', lastname);
|
|
133
|
-
line('age', age);
|
|
134
|
-
line('sex', sex);
|
|
135
|
-
FOR i IN 1 .. vehicle.COUNT LOOP
|
|
136
|
-
line('vehicle '||i, vehicle(i));
|
|
137
|
-
END LOOP;
|
|
138
|
-
htp.p('</table>');
|
|
139
|
-
closePage();
|
|
140
|
-
END pageFormProcess;
|
|
141
|
-
|
|
142
|
-
PROCEDURE pageFileUpload
|
|
143
|
-
IS
|
|
144
|
-
BEGIN
|
|
145
|
-
openPage('web_plsql - File upload');
|
|
146
|
-
htp.p('<form enctype="multipart/form-data" method="POST" action="!sample.pageFileUploaded">');
|
|
147
|
-
htp.p('<p>File 1: <input type="file" name="file1" /></p>');
|
|
148
|
-
htp.p('<p>File 2: <input type="file" name="file2" /></p>');
|
|
149
|
-
htp.p('<p>File 3: <input type="file" name="file3" /></p>');
|
|
150
|
-
htp.p('<p><input type="submit" name="submit" value"Upload" /></p>');
|
|
151
|
-
htp.p('</form>');
|
|
152
|
-
closePage();
|
|
153
|
-
END pageFileUpload;
|
|
154
|
-
|
|
155
|
-
PROCEDURE pageFileUploaded(name_array IN owa.vc_arr, value_array IN owa.vc_arr)
|
|
156
|
-
IS
|
|
157
|
-
BEGIN
|
|
158
|
-
openPage('web_plsql - File uploaded');
|
|
159
|
-
htp.p('<table>');
|
|
160
|
-
htp.p('<tr><th>name</th><th>value</th></tr>');
|
|
161
|
-
FOR i IN 1 .. name_array.COUNT LOOP
|
|
162
|
-
htp.p('<tr><td>'||name_array(i)||'</td><td>'||value_array(i)||'</td></tr>');
|
|
163
|
-
END LOOP;
|
|
164
|
-
htp.p('</table>');
|
|
165
|
-
closePage();
|
|
166
|
-
END pageFileUploaded;
|
|
167
|
-
|
|
168
|
-
PROCEDURE pageRedirect
|
|
169
|
-
IS
|
|
170
|
-
BEGIN
|
|
171
|
-
owa_util.mime_header('text/html', FALSE);
|
|
172
|
-
owa_cookie.send('fromPage', 'sample.pageRedirect');
|
|
173
|
-
owa_util.redirect_url(curl=>'sample.pageOther', bclose_header=>FALSE);
|
|
174
|
-
owa_util.http_header_close;
|
|
175
|
-
END pageRedirect;
|
|
176
|
-
|
|
177
|
-
PROCEDURE pageLocation
|
|
178
|
-
IS
|
|
179
|
-
BEGIN
|
|
180
|
-
openPage('web_plsql - pageLocation');
|
|
181
|
-
htp.p('<script>self.top.location.replace("sample.pageOther");</script>');
|
|
182
|
-
closePage();
|
|
183
|
-
END pageLocation;
|
|
184
|
-
|
|
185
|
-
PROCEDURE pageOther
|
|
186
|
-
IS
|
|
187
|
-
BEGIN
|
|
188
|
-
openPage('web_plsql - Other page');
|
|
189
|
-
closePage();
|
|
190
|
-
END pageOther;
|
|
191
|
-
|
|
192
|
-
PROCEDURE pagePathAlias(p_path IN VARCHAR2)
|
|
193
|
-
IS
|
|
194
|
-
BEGIN
|
|
195
|
-
openPage('web_plsql - pathAlias page');
|
|
196
|
-
htp.p('<p>p_path: "'||p_path||'"</p>');
|
|
197
|
-
closePage();
|
|
198
|
-
END pagePathAlias;
|
|
199
|
-
|
|
200
|
-
PROCEDURE openPage(title IN VARCHAR2)
|
|
201
|
-
IS
|
|
202
|
-
BEGIN
|
|
203
|
-
htp.p('<!DOCTYPE html>');
|
|
204
|
-
htp.p('<html>');
|
|
205
|
-
htp.p('<head>');
|
|
206
|
-
htp.p('<title>'||title||'</title>');
|
|
207
|
-
htp.p('<meta charset="utf-8">');
|
|
208
|
-
htp.p('<link rel="stylesheet" type="text/css" href="/static/sample.css" />');
|
|
209
|
-
htp.p('</head>');
|
|
210
|
-
htp.p('<body>');
|
|
211
|
-
htp.p('<h1>'||title||'</h1>');
|
|
212
|
-
htp.p('<p><a href="sample.pageIndex">Menu</a></p>');
|
|
213
|
-
END openPage;
|
|
214
|
-
|
|
215
|
-
PROCEDURE closePage
|
|
216
|
-
IS
|
|
217
|
-
BEGIN
|
|
218
|
-
htp.p('</body>');
|
|
219
|
-
htp.p('</html>');
|
|
220
|
-
END closePage;
|
|
221
|
-
|
|
222
|
-
END sample;
|
|
223
|
-
/
|
package/examples/sql/sample.pks
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
CREATE OR REPLACE
|
|
2
|
-
PACKAGE sample IS
|
|
3
|
-
|
|
4
|
-
TYPE vc_arr IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;
|
|
5
|
-
|
|
6
|
-
FUNCTION emptyArray RETURN vc_arr;
|
|
7
|
-
|
|
8
|
-
PROCEDURE pageIndex(p IN VARCHAR2 DEFAULT NULL);
|
|
9
|
-
PROCEDURE pageSimple(text IN VARCHAR2 DEFAULT NULL);
|
|
10
|
-
PROCEDURE pageFlexible(name_array IN owa.vc_arr, value_array IN owa.vc_arr);
|
|
11
|
-
PROCEDURE pageArray(text IN vc_arr);
|
|
12
|
-
PROCEDURE pageCGI;
|
|
13
|
-
PROCEDURE pageCookie;
|
|
14
|
-
PROCEDURE pageForm;
|
|
15
|
-
PROCEDURE pageFormProcess(firstname IN VARCHAR2 DEFAULT NULL, lastname IN VARCHAR2 DEFAULT NULL, age IN VARCHAR2 DEFAULT NULL, sex IN VARCHAR2 DEFAULT NULL, vehicle IN vc_arr DEFAULT emptyArray);
|
|
16
|
-
PROCEDURE pageFileUpload;
|
|
17
|
-
PROCEDURE pageFileUploaded(name_array IN owa.vc_arr, value_array IN owa.vc_arr);
|
|
18
|
-
PROCEDURE pageRedirect;
|
|
19
|
-
PROCEDURE pageLocation;
|
|
20
|
-
PROCEDURE pageOther;
|
|
21
|
-
PROCEDURE pagePathAlias(p_path IN VARCHAR2);
|
|
22
|
-
|
|
23
|
-
END sample;
|
|
24
|
-
/
|