@@ -5922,20 +5922,30 @@ a [`maxArraySize`](#executebindParams) property is also required
5922
5922
The [`results`](#executecallback) parameter of the `execute()`
5923
5923
callback contains an [`outBinds`](#execoutbinds) property with the
5924
5924
returned OUT and IN OUT bind values.
5925
- If [`bindParams`](#executebindParams) was passed as an array, then
5926
- `outBinds` is returned as an array, with the same order as the binds
5927
- in the statement. If `bindParams` was passed as an object, then
5928
- `outBinds` is returned as an object.
5929
5925
5930
- Here is an example program showing the use of binds:
5926
+ Given the creation of the PL/SQL procedure `TESTPROC`:
5927
+
5928
+ ```sql
5929
+ CREATE OR REPLACE PROCEDURE testproc (
5930
+ p_in IN VARCHAR2, p_inout IN OUT VARCHAR2, p_out OUT NUMBER)
5931
+ AS
5932
+ BEGIN
5933
+ p_inout := p_in || p_inout;
5934
+ p_out := 101;
5935
+ END;
5936
+ /
5937
+ show errors
5938
+ ```
5939
+
5940
+ The procedure `TESTPROC` can be called with:
5931
5941
5932
5942
```javascript
5933
5943
var oracledb = require('oracledb');
5934
5944
. . .
5935
5945
var bindVars = {
5936
5946
i: ' Chris' , // default direction is BIND_IN. Data type is inferred from the data
5937
5947
io: { val: ' Jones' , dir: oracledb .BIND_INOUT },
5938
- o: { type : oracledb .NUMBER , dir : oracledb .BIND_OUT },
5948
+ o: { dir : oracledb .BIND_OUT , type : oracledb .NUMBER },
5939
5949
}
5940
5950
connection .execute (
5941
5951
" BEGIN testproc(:i, :io, :o); END;" ,
@@ -5946,27 +5956,21 @@ connection.execute(
5946
5956
});
5947
5957
` ` `
5948
5958
5949
- Given the creation of ` TESTPROC ` using:
5959
+ Since ` bindParams` is passed as an object, the ` outBinds` property is
5960
+ also an object. The Node.js output is:
5950
5961
5951
- ` ` ` sql
5952
- CREATE OR REPLACE PROCEDURE testproc (
5953
- p_in IN VARCHAR2 , p_inout IN OUT VARCHAR2 , p_out OUT NUMBER )
5954
- AS
5955
- BEGIN
5956
- p_inout := p_in || p_inout;
5957
- p_out := 101 ;
5958
- END ;
5959
- /
5960
- show errors
5962
+ ` ` `
5963
+ { io: ' ChrisJones' , o: 101 }
5961
5964
` ` `
5962
5965
5963
- The Node.js output would be:
5966
+ PL/SQL allows named parameters in procedure and function calls. This
5967
+ can be used in ` execute ()` like:
5964
5968
5965
5969
` ` `
5966
- { io : ' ChrisJones ' , o : 101 }
5970
+ " BEGIN testproc(p_in => :i, p_inout => :io, p_out => :o); END; " ,
5967
5971
` ` `
5968
5972
5969
- An alternative to the 'bind by name' syntax is 'bind by array' syntax:
5973
+ An alternative to node-oracledb's 'bind by name' syntax is 'bind by array' syntax:
5970
5974
5971
5975
` ` ` javascript
5972
5976
var bindVars = [
@@ -5976,6 +5980,14 @@ var bindVars = [
5976
5980
];
5977
5981
` ` `
5978
5982
5983
+ When [` bindParams` ](#executebindParams) is passed as an array, then
5984
+ ` outBinds` is returned as an array, with the same order as the OUT
5985
+ binds in the statement:
5986
+
5987
+ ` ` `
5988
+ [ ' ChrisJones' , 101 ]
5989
+ ` ` `
5990
+
5979
5991
Mixing positional and named syntax is not supported. The following
5980
5992
will throw an error:
5981
5993
0 commit comments