Parameters
- Last Updated: November 4, 2022
- 1 minute read
- DataDirect Connectors
- JDBC
- Autonomous REST Connector 6.0
- Documentation
Parameters
You can define one or more parameters in your function or procedure using the following syntax. When specifying multiple parameters, you must separate parameters with a comma.
Functions syntax:
([IN] name <data_type>[,...])
Procedures syntax:
([IN | OUT | INOUT] <data_type> [,...])
For procedures, you can specify IN, OUT, or
INOUT parameters. The default is IN.
Not that both OUT and INOUT parameters must be registered
in the procedure to be usable.
The following examples demonstrate using parameters.
Example 1:
CREATE PROCEDURE swap(INOUT i BIGINT, INOUT j BIGINT)
BEGIN ATOMIC
DECLARE k BIGINT;
SET k = i;
SET i = j;
SET j = k;
END
Example 2:
try (CallableStatement cs = c.prepareCall("CALL swap(?, ?)")) {
cs.registerOutParameter(1, Types.SQL_BIGINT);
cs.registerOutParameter(2, Types.SQL_BIGINT);
cs.setLong(1, value1);
cs.setLong(2, value2);
cs.execute();
Assert.assertEquals(cs.getLong(1), value2);
Assert.assertEquals(cs.getLong(2), value1);
}