Product Documentation

FairCom Java & .NET Stored Procedures

Previous Topic

Next Topic

SQLPStatement.getParam

When a procedure is called from another procedure, this method returns the value of the specified OUT/INOUT parameter of the called procedure as a Java object. This returned object must be typecasted to the appropriate type.

Format

public Object getParam(int field, short dType)

Returns

Returns the Object specified by the field value.

Parameters

field

An integer that specifies which argument value of the called procedure is to be returned (1 denotes the first parameter, 2 denotes the second, and so on).

If the specified parameter does not exists, FairCom DB SQL returns an error:

(error(-20145): Invalid field reference.)

dType

The expected data type of the returning parameter.

Throws

DhSQLException

Example


CREATE PROCEDURE swap_proc(IN param1 INTEGER,

OUT param2 INTEGER,

INOUT param3 INTEGER)

BEGIN

param2 = param3;

param3 = param1;

END


CREATE PROCEDURE call_swap_proc()

BEGIN

Integer val1 = new Integer(10);

Integer val2;

Integer val3 = new Integer(20);

SQLPStatement pstmt = new SQLPStatement("CALL swap_proc(?,?,?)");

pstmt.registerOutParam(2, INTEGER);

pstmt.registerOutParam(3, INTEGER);

pstmt.setParam(1, val1);

pstmt.setParam(3, val3);

pstmt.execute();

val2 = (Integer)pstmt.getParam(2, INTEGER);

val3 = (Integer)pstmt.getParam(3, INTEGER);

// process the val2 and val3

END

TOCIndex