@@ -475,6 +475,8 @@ For installation information, see the [Node-oracledb Installation Instructions][
475
475
- 17.4 [Using DBMS_OUTPUT](#dbmsoutput)
476
476
- 17.5 [Edition-Based Redefinition](#ebr)
477
477
- 17.6 [Implicit Results](#implicitresults)
478
+ - 17.7 [Creating PL/SQL Procedures and Functions](#plsqlcreate)
479
+ - 17.7. [PL/SQL Compilation Warnings](#plsqlcompwarnings)
478
480
18. [Working with CLOB, NCLOB and BLOB Data](#lobhandling)
479
481
- 18.1 [Simple Insertion of LOBs](#basiclobinsert)
480
482
- 18.2 [Simple LOB Queries and PL/SQL OUT Binds](#queryinglobs)
@@ -11416,9 +11418,6 @@ solutions:
11416
11418
PL/SQL stored procedures, functions and anonymous blocks can be called
11417
11419
from node-oracledb using [`execute()`](#execute).
11418
11420
11419
- Note the error property of the callback is not set when PL/SQL
11420
- "success with info" warnings such as compilation warnings occur.
11421
-
11422
11421
### <a name="plsqlproc"></a> 17.1 PL/SQL Stored Procedures
11423
11422
11424
11423
The PL/SQL procedure:
@@ -11815,6 +11814,67 @@ Implicit Result Set 2
11815
11814
11816
11815
A runnable example is in [impres.js][138].
11817
11816
11817
+ ### <a name="plsqlcreate"></a> 17.7 Creating PL/SQL Procedures and Functions
11818
+
11819
+ PL/SQL procedures and functions can easily be created in node-oracledb by
11820
+ calling `connection.execute()`, for example:
11821
+
11822
+ ```javascript
11823
+ await connection.execute(
11824
+ `CREATE OR REPLACE PROCEDURE no_proc
11825
+ (p_in IN VARCHAR2, p_inout IN OUT VARCHAR2, p_out OUT NUMBER)
11826
+ AS
11827
+ BEGIN
11828
+ p_inout := p_in || p_inout;
11829
+ p_out := 101;
11830
+ END;`
11831
+ );
11832
+
11833
+ ```
11834
+
11835
+ See the examples
11836
+ [plsqlproc.js](https://github.com/oracle/node-oracledb/tree/master/examples/plsqlproc.js)
11837
+ and
11838
+ [plsqlfunc.js](https://github.com/oracle/node-oracledb/tree/master/examples/plsqlfunc.js).
11839
+
11840
+ #### <a name="plsqlcompwarnings"></a> 17.7.1 PL/SQL Compilation Warnings
11841
+
11842
+ When creating PL/SQL procedures and functions in node-oracledb, compilation
11843
+ warnings must be manually checked for. This can be done by querying
11844
+ `USER_ERRORS` like:
11845
+
11846
+ ```javascript
11847
+ await connection.execute(
11848
+ `CREATE OR REPLACE PROCEDURE badproc AS
11849
+ BEGIN
11850
+ INVALID
11851
+ END;`);
11852
+
11853
+ const r = await connection.execute(
11854
+ `SELECT line, position, text
11855
+ FROM user_errors
11856
+ WHERE name = 'BADPROC' AND type = 'PROCEDURE'
11857
+ ORDER BY name, type, line, position`,
11858
+ [], { outFormat: oracledb.OUT_FORMAT_OBJECT }
11859
+ );
11860
+
11861
+ if (r.rows.length) {
11862
+ console.error(r.rows[0].TEXT);
11863
+ console.error('at line', r.rows[0].LINE, 'position', r.rows[0].POSITION);
11864
+ }
11865
+ ```
11866
+
11867
+ Output is like:
11868
+
11869
+ ```
11870
+ PLS-00103: Encountered the symbol "END" when expecting one of the following:
11871
+
11872
+ := . ( @ % ;
11873
+ The symbol ";" was substituted for "END" to continue.
11874
+
11875
+ at line 4 position 8
11876
+ ```
11877
+
11818
11878
## <a name="lobhandling"></a> 18. Working with CLOB, NCLOB and BLOB Data
11819
11879
11820
11880
Oracle Database uses LOB data types to store long objects. The CLOB type is used
0 commit comments