When the OpenEdge SQL Engine creates a stored procedure, it converts the type of any input and output parameters.

The java.lang package, part of the Java core classes, defines classes for all the primitive Java types that "wrap" values of the corresponding primitive type in an object. The OpenEdge SQL Engine converts the SQL data types declared for input and output parameters to one of these wrapper types, as shown in the following table.

Be sure to use wrapper types when declaring procedure variables to use as arguments to the getValue, setParam, and set methods. These methods take objects as arguments and will generate compilation errors if you pass a primitive type to them.

The following example illustrates the use of the Java wrapper type Long for a SQL type INTEGER:

CREATE PROCEDURE proc1(INOUT f1 char(50), INOUT f2 integer)
BEGIN
f1 = new String("new rising sun");
f2 = new Integer("999");
END
CREATE PROCEDURE proc2()
BEGIN
String in1 = new String("String type");
String out1 = new String();
Long out2 = new Long("0");
SQLCursor call_proc = new SQLCursor("call proc1(?, ?)");
call_proc.setParam(1,in1);
// In setParam you can use either String or String type
// for SQL types CHAR, and VARCHAR
call_proc.setParam(2,new Long("111"));
call_proc.open();
out1 = (String)call_proc.getParam(1,CHAR);
// getParam requires String type for CHAR
out2 = (Long)call_proc.getParam(2,INTEGER);
call_proc.close();
END

When the OpenEdge SQL Engine submits the Java class it creates from the stored procedure to the Java compiler, the compiler checks for data‑type consistency between the converted parameters and variables you declare in the body of the stored procedure.

To avoid type mismatch errors, use the data‑type mappings shown in the following table for declaring parameters and result‑set fields in the procedure specification and the Java variables in the procedure body.

Table 1. Mapping between SQL and Java data types
SQL type Java methods Java wrapper type
CHAR, VARCHAR All String
CHAR, VARCHAR set, setParam String
NUMERIC All java.math.BigDecimal
DECIMAL All java.math.BigDecimal
BIT All Boolean
TINYINT All Byte[1]
SMALLINT All Integer
INTEGER All Integer
BIGINT All Integer
REAL All Float
FLOAT All Double
DOUBLE PRECISION All Double
BINARY All Byte[ ]
VARBINARY All Byte[ ]
DATE All java.sql.Date
TIME All java.sql.Time
TIMESTAMP All java.sql.Timestamp