Skip to content

Commit 7a09f97

Browse files
committed
Update example PL/SQL function to use an OUT param
1 parent 582202b commit 7a09f97

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

examples/plsqlfunc.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. */
1+
/* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. */
22

33
/******************************************************************************
44
*
@@ -39,9 +39,10 @@ async function run() {
3939

4040
await connection.execute(
4141
`CREATE OR REPLACE FUNCTION no_func
42-
(p1_in IN VARCHAR2, p2_in IN VARCHAR2) RETURN VARCHAR2
42+
(p1_in IN VARCHAR2, p2_in IN VARCHAR2, p3_out OUT NUMBER) RETURN VARCHAR2
4343
AS
4444
BEGIN
45+
p3_out := 123;
4546
RETURN p1_in || ' ' || p2_in;
4647
END;`
4748
);
@@ -50,17 +51,18 @@ async function run() {
5051
//
5152
// The equivalent call with PL/SQL named parameter syntax is:
5253
// `BEGIN
53-
// :ret := no_func(p1_in => :p1, p2_in => :p2);
54+
// :ret := no_func(p1_in => :p1, p2_in => :p2, p3_out => :p3);
5455
// END;`
5556

5657
const result = await connection.execute(
5758
`BEGIN
58-
:ret := no_func(:p1, :p2);
59+
:ret := no_func(:p1, :p2, :p3);
5960
END;`,
6061
{
6162
p1: 'Chris', // Bind type is determined from the data. Default direction is BIND_IN
6263
p2: 'Jones',
63-
ret: { dir: oracledb.BIND_OUT, type: oracledb.STRING, maxSize: 40 }
64+
p3: { dir: oracledb.BIND_OUT, type: oracledb.NUMBER },
65+
ret: { dir: oracledb.BIND_OUT, type: oracledb.STRING, maxSize: 40 }
6466
});
6567

6668
console.log(result.outBinds);

0 commit comments

Comments
 (0)